Want to script a "Read Attribute" for a ZHA attached device

I have a Frient Motion Sensor Pro which happens to have a temperature sensor and illuminance sensor on-board, however readings from those additional sensors never seem to be updated in Home Assistant.

I have tried using the Core service like below to update it, but doesn’t help unfortunately.

service: homeassistant.update_entity
target:
  entity_id: sensor.frient_a_s_moszb_140_temperature

However if I use the Read Attribute option in the ZHA integration, I’m able to get a new value from the sensor and it shows as updated.

Anyone know a way to script that change so it can be called periodically?

Thanks in advance!

May have found the answer to my own question literally seconds later: GitHub - mdeweerd/zha-toolkit: 🧰 Zigbee Home Assistant Toolkit - service for "rare" Zigbee operations using ZHA on Home Assistant

Doing some testing now and will post again with my results.

1 Like

Well it works, I can force a reading from the temperature sensor and illuminance sensor.

Here’s my YAML, just note that the illuminance sensor on this device is still making insane readings, I’m sat in a dark room which the Hue sensor is reading 1lx but the frient still shows over 1000lx.

Temperate sensor seems fine though! Will monitor overnight now I can get regular readings.

alias: Update Frient Temperature
sequence:
  - service: zha_toolkit.attr_read
    data:
      ieee: sensor.frient_a_s_moszb_140_temperature
      use_cache: false
      force_update: true
      endpoint: 38
      cluster: 1026
      attribute: 0
      state_id: sensor.frient_a_s_moszb_140_temperature
      state_value_template: (value/100)|round(1)
      read_before_write: false
      write_if_equal: true
mode: single
icon: mdi:auto-fix