I would like to share my integration of the new STPH sensor with the daylight information. The STPH sensor uses a solar panel to power itself, making it difficult to know if the sensor is receiving enough light to function and if it’s positioned correctly in the house. There is a way to check the status of the panel through an attribute to integrate it into ZHA. Below is my method using the ZHA Toolkit:
- Add a bind from the Binary Output cluster of the product to the concentrator to report light presence information:
In the development tools, under the service tab, run this code while pressing the button on the STPH to put it in “config” mode for the next 10 seconds:
service: zha_toolkit.bind_ieee
data:
ieee: [STPH IEEE address, found in the device info section]
endpoint: 1
cluster: 16
dst_endpoint: 1
command_data: [Concentrator IEEE address, found in the device info section]
- In automation and scenes, under the Scripts tab, create the following script “DayLightRead” to read the attribute value indicating light presence reported by the STPH:
service: zha_toolkit.attr_read
data:
ieee: [STPH IEEE address, found in the device info section]
endpoint: 1
cluster: 16
attribute: 85
use_cache: true
state_id: script.daylight
allow_create: true
-
In automation and scenes, under the Automations tab, create the following automation to execute the script periodically to refresh the “script.daylight” object:
Trigger: “Trigger every minute of every hour” Action: "Run script “DayLightRead” -
Finally, add a graphical input linked to the “script.daylight” object to display its status in the Overview menu. Under Devices and Services, in the Inputs tab, create a binary_sensor entry displayed as Light with the following template:
{% if is_state("script.daylight", "Bool.true") -%}
on
{%- else -%}
off
{%- endif %}
Here the result :