correct me if I’m wrong but the second option would require to manually create additional sensors, which I’m trying to avoid.
I’ve tried the first option, but the attribute value won’t accept a template.
My syntax could definitely be wrong so feel free to comment; here’s the full automation:
ha_set_state is only for setting states - it’s not related to zigbee as such. I added this to zha-toolkit as I wanted such a method for some scripts/automations with zha-toolkit.
That is something else that zha-toolkit enables: you can use a template - it’s slightly different from the usual templates: you should not add the curly braces ( “{{ }}” ) as the template needs to be evaluated after fetching the value.
There is an example of “state_value_template” in the readme and also in this blueprint.
But you found that because of the 2nd part of your message.
Yes, setting the unit of measurement is an additionnal command. I do not think that the order is important.
In principle you just need to write this after a ha restart, but you can write it anytime.
The code that sets the state does not require that the “entity” exists already (if allow_create is “thruthy” (true/1)).