How to create a new sensor from existing zigbee device sensor

Hi all,

I have purchased a Zigbee device that doesn’t handle all the attributes of the clusters.
They are all listed here: GitHub - fairecasoimeme/Zlinky_TIC: Téléinformation Linky autoalimenté ZigBee 3.0

In fact, if I go to the device > Manage Zigbee device and I list the attributes of the existing cluster I can read the attribute I need:

Is there a way to take this attribute and add it to the available Sensors for the device?
Here:

I’m not sure were to start, if I should go with templates, Custom Quirk, ZHA Toolkit, Developer tools or other things in Home Assistant.

Can you please help me to figure this out?

Thank you !!
Nicolas

1 Like

You can’t ‘add anything to the sensor’ what you need is to get the hardware reporting what your information says the sensor should already be sending.

So fix it where the problem is at the connection to the sensor… Or… the way the integration reads the sensor.

This link takes you straight to the relevant section of the ZHA docs. How to understand what is supported. What happens if your device uses extended clusters and what to do about custom device support (you should read this section and at least the two that follow it titled ‘knowing which devices’ and ‘how to add support’

Adding support makes the device report when it’s reporting the states/attributes should show up.

Hello,

I ran into the same issue with the ZLinky TIC, and have a solution to share.

Objective: I wanted to retrieve attributes IINST1, IINST2, IINST3 from the device (see here for documentation: GitHub - fairecasoimeme/Zlinky_TIC: Téléinformation Linky autoalimenté ZigBee 3.0). These attributes can be queried manually through the Zigbee device management window in Home Assistant, but are unfortunately not exposed as sensors by the zha integration - as per the above post.

Resolution steps below.

Step 1: install zha toolkit, if not already present on your system.

Plenty of documentation available on how to do this… Don’t forget adding “zha_toolkit:” to your HA yaml configuration.

Step 2: Create Template sensors, for each attribute you need to expose as a sensor

Templates are added in Settings → Devices & services → Helpers:

Make sure to set an identity ID that is meaningful to you, and the appropriate options for the value you want to read.For example:

  • Device class: current
  • Unit of measurement: A
  • State class: measurement

Step 3: Create an automation to read the device attributes at a regular interval

For this step, you need to know the appropriate Cluster and Attribute IDs, for the attributes you want to read. Refer to the documentation of your device, or explore your device directly from zha with the “Manage Zigbee device” option.

Retrieve the values through automation, by calling the “attr_read” service of the zha toolkit, at the interval you need:

In my case, the resulting yaml for the automation looks like:

alias: Update Zlinky TIC sensors
description: ""
trigger:
  - platform: time_pattern
    minutes: /1
condition: []
action:
  - service: zha_toolkit.attr_read
    metadata: {}
    data:
      ieee: sensor.lixee_zlinky_tic_current
      state_id: sensor.lixee_zlinky_tic_puissance_instantanee_phase_1
      cluster: 2820
      attribute: 1288
  - service: zha_toolkit.attr_read
    metadata: {}
    data:
      ieee: sensor.lixee_zlinky_tic_current
      state_id: sensor.lixee_zlinky_tic_puissance_instantanee_phase_2
      cluster: 2820
      attribute: 2312
  - service: zha_toolkit.attr_read
    metadata: {}
    data:
      ieee: sensor.lixee_zlinky_tic_current
      state_id: sensor.lixee_zlinky_tic_puissance_instantanee_phase_3
      cluster: 2820
      attribute: 2568
mode: single

Reference material: Intégration zha · Issue #18 · fairecasoimeme/Zlinky_TIC (github.com)

Note - technically, as per the documentation, IINST1 = IINST (same Cluster/Attribute ID), which is already natively exposed by zha as a sensor through sensor.lixee_zlinky_tic_current. Only IINST2 and IINST3 are actually missing. - but somehow I prefer the consistency of handling all 3 the same way :slight_smile:

I hope this helps!