You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've started to think, how can we further improve our code?
My first thought was, start from the top: what does HA require as input data?
Device data to pass to HA:
connections: mac address(es)
(configuration_url: should be the gateway address as there are two config/setup-options)
hw_version
identifier: appliance_id
name
name_by_user
manufacturer
model
model_id
(serial_number: not available)
suggested_area: location name
sw_version: firmware version
(via_device: is the gateway)
Now we use dev_class only for finding Master_Thermostats, and for migration.
The migration-function is old, could be removed in the future.
Should we get rid of the dev_class? Maybe not because it tells us what the device-type is.
Maybe rename to device_type?
So, the dict to return should be:
{identifier: {device_type: ..., hw_version: ..., name: ..., name_by_user: ..., manufacturer: ..., model: ..., model_id: ..., suggested_area:... , sw_version:..., etc.}
What to so with the binary_sensors, sensors and switch dicts?
Keep and extent: add button, climate, number and select dicts? Would allow us to get rid of using device_class/_type.
Or remove them? We could prefix the various names with the platform-name?
Also, which data is fixed, which data requires refreshing?
name_by_user, suggested_area, sw_version might be updated, others are fixed unless there is a hardware update (new cv-ketel/warmtepomp), or e.g. a Lisa is replaced by a new one.
For instance, when changing the function of a Plug and renaming it to that new function, the backend picks that up but HA doesn't. Also a reload does not fix this if I remember it correctly. Maybe because we don't use the "name_by_user" attribute?
From looking at the HA code, it doesn't: "name_by_user" is the first pick, otherwise "name" is used for device-naming.
So, for us, using name and model are sufficient: name = Lisa badkamer, model = Lisa --> don't use "name_by_user".
So, the dict to return then becomes:
{identifier: {device_type: ..., hw_version: ..., name: ..., manufacturer: ..., model: ..., model_id: ..., suggested_area:... , sw_version:..., etc.}
We should detect a database reset --> how to handle? Remove and readd the integration? Or detect and force a reload?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I've started to think, how can we further improve our code?
My first thought was, start from the top: what does HA require as input data?
Device data to pass to HA:
Now we use
dev_class
only for finding Master_Thermostats, and for migration.The migration-function is old, could be removed in the future.
Should we get rid of the
dev_class
? Maybe not because it tells us what the device-type is.Maybe rename to
device_type
?So, the dict to return should be:
{identifier: {device_type: ..., hw_version: ..., name: ..., name_by_user: ..., manufacturer: ..., model: ..., model_id: ..., suggested_area:... , sw_version:..., etc.}
What to so with the
binary_sensors
,sensors
andswitch
dicts?button
,climate
,number
andselect
dicts? Would allow us to get rid of using device_class/_type.Also, which data is fixed, which data requires refreshing?
For instance, when changing the function of a Plug and renaming it to that new function, the backend picks that up but HA doesn't. Also a reload does not fix this if I remember it correctly. Maybe because we don't use the "name_by_user" attribute?
From looking at the HA code, it doesn't: "name_by_user" is the first pick, otherwise "name" is used for device-naming.
So, for us, using name and model are sufficient: name = Lisa badkamer, model = Lisa --> don't use "name_by_user".
So, the dict to return then becomes:
{identifier: {device_type: ..., hw_version: ..., name: ..., manufacturer: ..., model: ..., model_id: ..., suggested_area:... , sw_version:..., etc.}
We should detect a database reset --> how to handle? Remove and readd the integration? Or detect and force a reload?
@CoMPaTech have a read and feedback please.
Beta Was this translation helpful? Give feedback.
All reactions