Home Assistant entities are objects with a state value. State values are held internally as strings and can only be primitive data values such as a number or string. Even ‘boolean’ values are held as string-pair representations such as ‘on’ and ‘off’.
Entity objects also hold other values including an attribute, as an object, which can hold almost anything you like. Entity attributes are secondary values in Home Assistant and can be more difficult to work with. The dashboard entities card for example expects to show the entity-state value of each entity, but can also show a named attribute value.
Inverter settings like timed charge do require a complex set of values maintained as a ‘unit’. It is possible to create entities and group them using ‘device’, but this is more associated with something like a smart plug. The plug is the ‘device’ and there can be several entities associated with it, such as switch, temperature, WIFI signal strength. One solution would therefore be to group individual entities under a pseudo device.
The model for HVAC climate devices such as air conditioners is perhaps more useful. Any a/c unit will have several values representing both read only monitoring such as power used, energy consumed, and room temperature. There will be several settings for control, such as mode, fan speed, set temperature, and perhaps time control.
If you look at the HA generic climate integration, which is a building-block integration used to support real-world HVAC integrations, you will find that there is just one entity per a/c unit, with the entity attribute holding something like the following data structure.
hvac_modes:
- "off"
- heat
- dry
- cool
- fan_only
- heat_cool
min_temp: 16
max_temp: 31
target_temp_step: 0.5
fan_modes:
- auto
- "1"
- "2"
- "3"
- "4"
- "5"
swing_modes:
- auto
- 1_up
- "2"
- "3"
- "4"
- 5_down
- swing
swing_horizontal_modes:
- auto
- 1_left
- "2"
- "3"
- "4"
- 5_right
- split
- swing
current_temperature: 24
temperature: 21
fan_mode: auto
swing_mode: auto
swing_horizontal_mode: "3"
vane_horizontal: "3"
vane_horizontal_positions:
- auto
- 1_left
- "2"
- "3"
- "4"
- 5_right
- split
- swing
vane_vertical: auto
vane_vertical_positions:
- auto
- 1_up
- "2"
- "3"
- "4"
- 5_down
- swing
icon: mdi:air-conditioner
friendly_name: Bedroom Aircon
supported_features: 937
The only ‘HA standard’ attribute properties are the icon and friendly_name, used by HA in almost every entity. The remaining properties have been constructed and are maintained by the a/c integration I use.
The entity state value, in this case, is the current active mode, which is “off” at the moment, or will be “cool” when running (in that mode).
The challenge is not in developing one entity with a set of associated attribute properties, but rather in being able to manipulate the attributes correctly from within HA. Since Home Assistant is focused on entity-state, the climate entities require a special dashboard card that brings everything together as one.
The thermostat card is associated with just one entity, but brings all the entity-attributes for climate control into the one card. Modifying any one value brings about the necessary Action (service call) by the HA integration to make the necessary change(s). Here, changing the set-temperature is simply a single Action to set-temperature with the new value.
For something like an inverter timed-charge setting, you may need to consider the interaction between settings, and have a single ‘post-update’ button so as to pass the entire (new) setting ‘as one’.
You might actually end up with an HA dashboard card that looks rather like the Goodwe app UI
Happy developing.