I have one sensor configuration that just refuses to start reliably. It’s pulling the fan speed from a zwave fan control, and only ends up reporting nothing. Periodically after a reboot it works.
Here is the sensor from which it’s reporting:
fan.great_room_fan_level on
speed_list: off, low, medium, high
speed: low
node_id: 3
value_index: 0
value_instance: 1
value_id: 72057594093076481
friendly_name: Great Room Fan Level
supported_features: 1
icon: mdi:fan
The template sensor is attempting to extract the fan speed. It has bloated as I’ve tried elements from other threads and to make it seemingly bulletproof, to no avail:
- platform: template
sensors:
... other sensors ...
great_room_fan_speed:
friendly_name: "Great Room Fan Speed Setting"
value_template: >-
{% set tu = states.sensor.uptime.state | float %}
{% if tu > 0.03 %}
{% if is_state('fan.great_room_fan_level', 'Unknown') %}
'off'
{% elif is_state('fan.great_room_fan_level', 'on') %}
{% if states.fan.great_room_fan_level.attributes.speed == 'off' or
states.fan.great_room_fan_level.attributes.speed == 'low' or
states.fan.great_room_fan_level.attributes.speed == 'medium' or
states.fan.great_room_fan_level.attributes.speed == 'high' %}
{{ states.fan.great_room_fan_level.attributes.speed }}
{% else %}
'low'
{% endif %}
{% else %}
'off'
{% endif %}
{% else %}
'off'
{% endif %}
icon_template: mdi:fan
entity_id:
- fan.great_room_fan_level
The entity gets created but nothing is ever reported in the “state” field.
I started off just making sure the entity fan.great_room_fan_level existed and added complexity from there. The last attempt was to force it to ‘off’ until home assistant has been running for a few minutes, but I’m guessing the issue is somewhere else.
One other bit of information is that I originally had this zwave fan control running from Vera, which reported this as a “brightness” from 0 to 255. When I first moved this to an Aeotec stick, the entity it created reported the speed as controllable from 0 to 255, but then after some time changed to the ‘off’, ‘low’, etc.
I’m wondering if something happens during startup that’s confusing either openzwave or HA. I can run the above config (and it’s dozen or so predecessors) in the template and it reports correct results.
If I run home_assistant.update_entity to update this sensor, it stays stuck (so to speak) even though the template reports correct results from the fan entity – is there some behind-the-scenes update process that gets stuck at startup and blocks updating of the entity until it completes? I’m somewhat lost how to troubleshoot this further.
No errors or warnings in the log, although I haven’t enabled debug level logging. That will be my next step, I guess, when next I try something else.