Hmmm…I seem to be chasing my tail a bit here…so here are the sensor definitions:
- name: "Vallhorn Landing Illuminance"
device_class: illuminance
state_topic: "tele/zigbee-bridge/vallhorn-landing/SENSOR"
value_template: >
{{ value_json['ZbReceived']['0x4D91']['Illuminance']
if value_json['ZbReceived']['0x4D91']['Illuminance'] is defined
else this.state | default(0, true) }}
- name: "Vallhorn Hall Illuminance"
device_class: Illuminance
state_topic: "tele/zigbee-bridge/vallhorn-hall/SENSOR"
value_template: >
{{ value_json['ZbReceived']['0x1252']['Illuminance']
if value_json['ZbReceived']['0x1252']['Illuminance'] is defined
else this.state | default(0, true) }}
…and here are the binary sensors:
- name: "PIR Vallhorn Landing"
state_topic: "tele/zigbee-bridge/vallhorn-landing/SENSOR"
device_class: occupancy
value_template: >
{% set x = value_json['ZbReceived']['0x4D91']['Occupancy']
if value_json['ZbReceived']['0x4D91']['Occupancy'] is defined
else this.state | default(0, true) %}
{{ x | int(0) == 1 }}
#Vallhorn PIR in Hall
- name: "PIR Vallhorn Hall"
state_topic: "tele/zigbee-bridge/vallhorn-hall/SENSOR"
device_class: occupancy
value_template: >
{% set x = value_json['ZbReceived']['0x1252']['Occupancy']
if value_json['ZbReceived']['0x1252']['Occupancy'] is defined
else this.state | default(0, true) %}
{{ x | int(0) == 1 }}
…and these are the error messages that I am now seeing in the log:
ERROR (MainThread) [homeassistant.components.mqtt.models] Exception raised while updating state of sensor.vallhorn_landing_illuminance, topic: 'tele/zigbee-bridge/vallhorn-landing/SENSOR' with payload: b'{"ZbReceived":{"0x4D91":{"Device":"0x4D91","Name":"vallhorn-landing","Occupancy":0,"Endpoint":2,"LinkQuality":34}}}'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 658, in state
numerical_value = int(value)
^^^^^^^^^^
ValueError: invalid literal for int() with base 10: 'unknown'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 661, in state
numerical_value = float(value)
^^^^^^^^^^^^
ValueError: could not convert string to float: 'unknown'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/mqtt/models.py", line 380, in process_write_state_requests
entity.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1000, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1126, in _async_write_ha_state
state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1061, in __async_calculate_state
state = self._stringify_state(available)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1006, in _stringify_state
if (state := self.state) is None:
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 665, in state
raise ValueError(
ValueError: Sensor sensor.vallhorn_landing_illuminance has device class 'illuminance', state class 'None' unit 'None' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: 'unknown' (<class 'str'>)
2024-07-30 21:44:37.676 INFO (MainThread) [homeassistant.components.mqtt.binary_sensor] No matching payload found for entity: binary_sensor.pir_vallhorn_hall with state topic: tele/zigbee-bridge/vallhorn-hall/SENSOR. Payload: '{"ZbReceived":{"0x1252":{"Device":"0x1252","Name":"vallhorn-hall","0006!42":"0058020000","Power":1,"PowerOnlyWhenOn":0,"PowerOnTime":60,"PowerOffWait":0,"Endpoint":1,"LinkQuality":81}}}', template output: 'False', with value template 'Template<template=({% set x = value_json['ZbReceived']['0x1252']['Occupancy']
if value_json['ZbReceived']['0x1252']['Occupancy'] is defined
else this.state | default(0, true) %}
{{ x | int(0) == 1 }}) renders=1>'
2024-07-30 21:44:37.677 ERROR (MainThread) [homeassistant.components.mqtt.models] Exception raised while updating state of sensor.vallhorn_hall_illuminance, topic: 'tele/zigbee-bridge/vallhorn-hall/SENSOR' with payload: b'{"ZbReceived":{"0x1252":{"Device":"0x1252","Name":"vallhorn-hall","0006!42":"0058020000","Power":1,"PowerOnlyWhenOn":0,"PowerOnTime":60,"PowerOffWait":0,"Endpoint":1,"LinkQuality":81}}}'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 658, in state
numerical_value = int(value)
^^^^^^^^^^
ValueError: invalid literal for int() with base 10: 'unknown'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 661, in state
numerical_value = float(value)
^^^^^^^^^^^^
ValueError: could not convert string to float: 'unknown'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/mqtt/models.py", line 380, in process_write_state_requests
entity.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1000, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1126, in _async_write_ha_state
state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1061, in __async_calculate_state
state = self._stringify_state(available)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1006, in _stringify_state
if (state := self.state) is None:
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 665, in state
raise ValueError(
ValueError: Sensor sensor.vallhorn_hall_illuminance has device class 'illuminance', state class 'None' unit 'None' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: 'unknown' (<class 'str'>)
2024-07-30 21:44:38.052 INFO (MainThread) [homeassistant.components.mqtt.binary_sensor] No matching payload found for entity: binary_sensor.pir_vallhorn_hall with state topic: tele/zigbee-bridge/vallhorn-hall/SENSOR. Payload: '{"ZbReceived":{"0x1252":{"Device":"0x1252","Name":"vallhorn-hall","Occupancy":1,"Endpoint":2,"LinkQuality":81}}}', template output: 'True', with value template 'Template<template=({% set x = value_json['ZbReceived']['0x1252']['Occupancy']
if value_json['ZbReceived']['0x1252']['Occupancy'] is defined
else this.state | default(0, true) %}
{{ x | int(0) == 1 }}) renders=2>'