[ST Edge] Zigbee Illuminance Measurement

Thanks Mariano I have tried this method however I still do not see a value for illuminance. I get logs for battery but no illuminance.

Neither is the sending of the configuration and the response seen in the logs?

The defaultedge libraries when executing device: configure() does not send default configuration for illuminance.
Have to send it manually and until it is accepted by the device, it does not send reports. That is my experience with the sensor that I tested it

1 Like

Here is the logs received using the cli. I have tried removing/ re-adding the device as well as leaving the device overnight to see if a value is sent.

2021-12-23T18:17:45.869820879+00:00 TRACE Xiaomi Luminance Sensor BG4  Setup driver xiaomi-illuminance with lifecycle handlers:
DeviceLifecycleDispatcher: xiaomi-illuminance
  default_handlers:
    doConfigure:
    driverSwitched:
  child_dispatchers:
    DeviceLifecycleDispatcher: xiaomi-illuminance -> LUMI Illuminance Handler
      default_handlers:
      child_dispatchers:

2021-12-23T18:17:45.882763879+00:00 TRACE Xiaomi Luminance Sensor BG4  Setup driver xiaomi-illuminance with Capability handlers:
CapabilityCommandDispatcher: xiaomi-illuminance
  default_handlers:
    refresh:
      refresh
  child_dispatchers:
    CapabilityCommandDispatcher: xiaomi-illuminance -> LUMI Illuminance Handler
      default_handlers:
      child_dispatchers:

2021-12-23T18:17:45.899972879+00:00 TRACE Xiaomi Luminance Sensor BG4  Setup driver xiaomi-illuminance with Zigbee handlers:
ZigbeeMessageDispatcher: xiaomi-illuminance
  default_handlers:
    attr:
      ZclClusterAttributeValueHandler: cluster: PowerConfiguration, attribute: BatteryVoltage
      ZclClusterAttributeValueHandler: cluster: PowerConfiguration, attribute: BatteryPercentageRemaining
      ZclClusterAttributeValueHandler: cluster: Basic, attribute: 0xFF02
      ZclClusterAttributeValueHandler: cluster: Basic, attribute: 0xFF01
      ZclClusterAttributeValueHandler: cluster: IlluminanceMeasurement, attribute: MeasuredValue
    global:
    cluster:
    zdo:
  child_dispatchers:
    ZigbeeMessageDispatcher: xiaomi-illuminance -> LUMI Illuminance Handler
      default_handlers:
        attr:
          ZclClusterAttributeValueHandler: cluster: IlluminanceMeasurement, attribute: MeasuredValue
        global:
        cluster:
        zdo:
      child_dispatchers:

2021-12-23T18:17:46.004136212+00:00 TRACE Xiaomi Luminance Sensor BG4  Received event with handler _resync
2021-12-23T18:17:46.009904212+00:00 TRACE Xiaomi Luminance Sensor BG4  Received event with handler environment_info
2021-12-23T18:17:46.044573879+00:00 TRACE Xiaomi Luminance Sensor BG4  <ZigbeeDevice: 31c7f8fe-eaec-4ee5-b0af-8305aa42167e [0x2D44] (Xiaomi Luminance Sensor)> received unhandled lifecycle event: init
2021-12-23T18:17:46.056013546+00:00 DEBUG Xiaomi Luminance Sensor BG4  Xiaomi Luminance Sensor device thread event handled
2021-12-23T18:17:46.068685879+00:00 TRACE Xiaomi Luminance Sensor BG4  Received event with handler _resync
2021-12-23T18:17:46.084652879+00:00 TRACE Xiaomi Luminance Sensor BG4  Received event with handler environment_info
2021-12-23T18:17:46.095845213+00:00 DEBUG Xiaomi Luminance Sensor BG4  Z-Wave hub node ID environment changed.
2021-12-23T18:17:46.103286879+00:00 TRACE Xiaomi Luminance Sensor BG4  Received event with handler device_lifecycle
2021-12-23T18:17:46.113929879+00:00 INFO Xiaomi Luminance Sensor BG4  <ZigbeeDevice: 31c7f8fe-eaec-4ee5-b0af-8305aa42167e [0x2D44] (Xiaomi Luminance Sensor)> received lifecycle event: added
2021-12-23T18:17:46.124836546+00:00 TRACE Xiaomi Luminance Sensor BG4  <ZigbeeDevice: 31c7f8fe-eaec-4ee5-b0af-8305aa42167e [0x2D44] (Xiaomi Luminance Sensor)> received unhandled lifecycle event: added
2021-12-23T18:17:46.141133546+00:00 DEBUG Xiaomi Luminance Sensor BG4  Xiaomi Luminance Sensor device thread event handled
2021-12-23T18:17:46.147193213+00:00 TRACE Xiaomi Luminance Sensor BG4  Received event with handler device_lifecycle
2021-12-23T18:17:46.152842879+00:00 INFO Xiaomi Luminance Sensor BG4  <ZigbeeDevice: 31c7f8fe-eaec-4ee5-b0af-8305aa42167e [0x2D44] (Xiaomi Luminance Sensor)> received lifecycle event: driverSwitched
2021-12-23T18:17:46.173009213+00:00 TRACE Xiaomi Luminance Sensor BG4  Found DeviceLifecycleDispatcher handler in xiaomi-illuminance
2021-12-23T18:17:46.178280546+00:00 DEBUG Xiaomi Luminance Sensor BG4  Xiaomi Luminance Sensor device thread event handled
2021-12-23T18:17:46.203834546+00:00 DEBUG Xiaomi Luminance Sensor BG4  Xiaomi Luminance Sensor device thread event handled
2021-12-23T18:17:46.475747546+00:00 TRACE Xiaomi Luminance Sensor BG4  Received event with handler device_lifecycle
2021-12-23T18:17:46.489376546+00:00 INFO Xiaomi Luminance Sensor BG4  <ZigbeeDevice: 31c7f8fe-eaec-4ee5-b0af-8305aa42167e [0x2D44] (Xiaomi Luminance Sensor)> received lifecycle event: infoChanged   
2021-12-23T18:17:46.506329879+00:00 TRACE Xiaomi Luminance Sensor BG4  <ZigbeeDevice: 31c7f8fe-eaec-4ee5-b0af-8305aa42167e [0x2D44] (Xiaomi Luminance Sensor)> received unhandled lifecycle event: infoChanged
2021-12-23T18:17:46.517272546+00:00 DEBUG Xiaomi Luminance Sensor BG4  Xiaomi Luminance Sensor device thread event handled
2021-12-23T18:18:07.087448556+00:00 TRACE Xiaomi Luminance Sensor BG4  Received event with handler capability
2021-12-23T18:18:07.105561223+00:00 INFO Xiaomi Luminance Sensor BG4  <ZigbeeDevice: 31c7f8fe-eaec-4ee5-b0af-8305aa42167e [0x2D44] (Xiaomi Luminance Sensor)> received command: {"command":"refresh","positional_args":[],"component":"main","args":[],"capability":"refresh"}
2021-12-23T18:18:07.111812223+00:00 TRACE Xiaomi Luminance Sensor BG4  Found CapabilityCommandDispatcher handler in xiaomi-illuminance
2021-12-23T18:18:07.142740556+00:00 INFO Xiaomi Luminance Sensor BG4  <ZigbeeDevice: 31c7f8fe-eaec-4ee5-b0af-8305aa42167e [0x2D44] (Xiaomi Luminance Sensor)> sending Zigbee message: < ZigbeeMessageTx || Uint16: 0x0000, < AddressHeader || src_addr: 0x0000, src_endpoint: 0x01, dest_addr: 0x2D44, dest_endpoint: 0x01, profile: 0x0104, cluster: PowerConfiguration >, < ZCLMessageBody || < ZCLHeader || frame_ctrl: 0x00, seqno: 0x00, ZCLCommandId: 0x00 >, < ReadAttribute || AttributeId: 0x0021 > > >
2021-12-23T18:18:07.165015889+00:00 DEBUG Xiaomi Luminance Sensor BG4  Xiaomi Luminance Sensor device thread event handled
2021-12-23T18:18:08.107829223+00:00 TRACE Xiaomi Luminance Sensor BG4  Received event with handler capability
2021-12-23T18:18:08.146275556+00:00 INFO Xiaomi Luminance Sensor BG4  <ZigbeeDevice: 31c7f8fe-eaec-4ee5-b0af-8305aa42167e [0x2D44] (Xiaomi Luminance Sensor)> received command: {"command":"refresh","positional_args":[],"component":"main","args":[],"capability":"refresh"}
2021-12-23T18:18:08.217387556+00:00 TRACE Xiaomi Luminance Sensor BG4  Found CapabilityCommandDispatcher handler in xiaomi-illuminance
2021-12-23T18:18:08.270362223+00:00 INFO Xiaomi Luminance Sensor BG4  <ZigbeeDevice: 31c7f8fe-eaec-4ee5-b0af-8305aa42167e [0x2D44] (Xiaomi Luminance Sensor)> sending Zigbee message: < ZigbeeMessageTx || Uint16: 0x0000, < AddressHeader || src_addr: 0x0000, src_endpoint: 0x01, dest_addr: 0x2D44, dest_endpoint: 0x01, profile: 0x0104, cluster: PowerConfiguration >, < ZCLMessageBody || < ZCLHeader || frame_ctrl: 0x00, seqno: 0x00, ZCLCommandId: 0x00 >, < ReadAttribute || AttributeId: 0x0021 > > >
2021-12-23T18:18:08.391121223+00:00 DEBUG Xiaomi Luminance Sensor BG4  Xiaomi Luminance Sensor device thread event handled
2021-12-23T18:18:09.125761890+00:00 TRACE Xiaomi Luminance Sensor BG4  Received event with handler capability
2021-12-23T18:18:09.135442890+00:00 INFO Xiaomi Luminance Sensor BG4  <ZigbeeDevice: 31c7f8fe-eaec-4ee5-b0af-8305aa42167e [0x2D44] (Xiaomi Luminance Sensor)> received command: {"command":"refresh","positional_args":[],"component":"main","args":[],"capability":"refresh"}
2021-12-23T18:18:09.141918557+00:00 TRACE Xiaomi Luminance Sensor BG4  Found CapabilityCommandDispatcher handler in xiaomi-illuminance
2021-12-23T18:18:09.154473557+00:00 INFO Xiaomi Luminance Sensor BG4  <ZigbeeDevice: 31c7f8fe-eaec-4ee5-b0af-8305aa42167e [0x2D44] (Xiaomi Luminance Sensor)> sending Zigbee message: < ZigbeeMessageTx || Uint16: 0x0000, < AddressHeader || src_addr: 0x0000, src_endpoint: 0x01, dest_addr: 0x2D44, dest_endpoint: 0x01, profile: 0x0104, cluster: PowerConfiguration >, < ZCLMessageBody || < ZCLHeader || frame_ctrl: 0x00, seqno: 0x00, ZCLCommandId: 0x00 >, < ReadAttribute || AttributeId: 0x0021 > > >
2021-12-23T18:18:09.185983890+00:00 DEBUG Xiaomi Luminance Sensor BG4  Xiaomi Luminance Sensor device thread event handled
2021-12-23T18:18:10.305270557+00:00 TRACE Xiaomi Luminance Sensor BG4  Received event with handler capability
2021-12-23T18:18:10.320132224+00:00 INFO Xiaomi Luminance Sensor BG4  <ZigbeeDevice: 31c7f8fe-eaec-4ee5-b0af-8305aa42167e [0x2D44] (Xiaomi Luminance Sensor)> received command: {"command":"refresh","positional_args":[],"component":"main","args":[],"capability":"refresh"}
2021-12-23T18:18:10.326855891+00:00 TRACE Xiaomi Luminance Sensor BG4  Found CapabilityCommandDispatcher handler in xiaomi-illuminance
2021-12-23T18:18:10.334529891+00:00 INFO Xiaomi Luminance Sensor BG4  <ZigbeeDevice: 31c7f8fe-eaec-4ee5-b0af-8305aa42167e [0x2D44] (Xiaomi Luminance Sensor)> sending Zigbee message: < ZigbeeMessageTx || Uint16: 0x0000, < AddressHeader || src_addr: 0x0000, src_endpoint: 0x01, dest_addr: 0x2D44, dest_endpoint: 0x01, profile: 0x0104, cluster: PowerConfiguration >, < ZCLMessageBody || < ZCLHeader || frame_ctrl: 0x00, seqno: 0x00, ZCLCommandId: 0x00 >, < ReadAttribute || AttributeId: 0x0021 > > >
2021-12-23T18:18:10.371618557+00:00 DEBUG Xiaomi Luminance Sensor BG4  Xiaomi Luminance Sensor device thread event handled
2021-12-23T18:18:11.395801558+00:00 TRACE Xiaomi Luminance Sensor BG4  Received event with handler capability
2021-12-23T18:18:11.405397891+00:00 INFO Xiaomi Luminance Sensor BG4  <ZigbeeDevice: 31c7f8fe-eaec-4ee5-b0af-8305aa42167e [0x2D44] (Xiaomi Luminance Sensor)> received command: {"command":"refresh","positional_args":[],"component":"main","args":[],"capability":"refresh"}
2021-12-23T18:18:11.420349558+00:00 TRACE Xiaomi Luminance Sensor BG4  Found CapabilityCommandDispatcher handler in xiaomi-illuminance
2021-12-23T18:18:11.450973225+00:00 INFO Xiaomi Luminance Sensor BG4  <ZigbeeDevice: 31c7f8fe-eaec-4ee5-b0af-8305aa42167e [0x2D44] (Xiaomi Luminance Sensor)> sending Zigbee message: < ZigbeeMessageTx || Uint16: 0x0000, < AddressHeader || src_addr: 0x0000, src_endpoint: 0x01, dest_addr: 0x2D44, dest_endpoint: 0x01, profile: 0x0104, cluster: PowerConfiguration >, < ZCLMessageBody || < ZCLHeader || frame_ctrl: 0x00, seqno: 0x00, ZCLCommandId: 0x00 >, < ReadAttribute || AttributeId: 0x0021 > > >
2021-12-23T18:18:11.480507225+00:00 DEBUG Xiaomi Luminance Sensor BG4  Xiaomi Luminance Sensor device thread event handled
2021-12-23T18:18:15.942098227+00:00 TRACE Xiaomi Luminance Sensor BG4  Received event with handler zigbee health poll
2021-12-23T18:18:16.203620560+00:00 TRACE Xiaomi Luminance Sensor BG4  Received event with handler capability
2021-12-23T18:18:16.217517227+00:00 INFO Xiaomi Luminance Sensor BG4  <ZigbeeDevice: 31c7f8fe-eaec-4ee5-b0af-8305aa42167e [0x2D44] (Xiaomi Luminance Sensor)> received command: {"command":"refresh","positional_args":[],"component":"main","args":[],"capability":"refresh"}
2021-12-23T18:18:16.230828894+00:00 TRACE Xiaomi Luminance Sensor BG4  Found CapabilityCommandDispatcher handler in xiaomi-illuminance
2021-12-23T18:18:16.238418894+00:00 INFO Xiaomi Luminance Sensor BG4  <ZigbeeDevice: 31c7f8fe-eaec-4ee5-b0af-8305aa42167e [0x2D44] (Xiaomi Luminance Sensor)> sending Zigbee message: < ZigbeeMessageTx || Uint16: 0x0000, < AddressHeader || src_addr: 0x0000, src_endpoint: 0x01, dest_addr: 0x2D44, dest_endpoint: 0x01, profile: 0x0104, cluster: PowerConfiguration >, < ZCLMessageBody || < ZCLHeader || frame_ctrl: 0x00, seqno: 0x00, ZCLCommandId: 0x00 >, < ReadAttribute || AttributeId: 0x0021 > > >
2021-12-23T18:18:16.270463894+00:00 DEBUG Xiaomi Luminance Sensor BG4  Xiaomi Luminance Sensor device thread event handled
2021-12-23T18:18:17.417172227+00:00 TRACE Xiaomi Luminance Sensor BG4  Received event with handler capability
2021-12-23T18:18:17.426564227+00:00 INFO Xiaomi Luminance Sensor BG4  <ZigbeeDevice: 31c7f8fe-eaec-4ee5-b0af-8305aa42167e [0x2D44] (Xiaomi Luminance Sensor)> received command: {"command":"refresh","positional_args":[],"component":"main","args":[],"capability":"refresh"}
2021-12-23T18:18:17.432998227+00:00 TRACE Xiaomi Luminance Sensor BG4  Found CapabilityCommandDispatcher handler in xiaomi-illuminance
2021-12-23T18:18:17.444932561+00:00 INFO Xiaomi Luminance Sensor BG4  <ZigbeeDevice: 31c7f8fe-eaec-4ee5-b0af-8305aa42167e [0x2D44] (Xiaomi Luminance Sensor)> sending Zigbee message: < ZigbeeMessageTx || Uint16: 0x0000, < AddressHeader || src_addr: 0x0000, src_endpoint: 0x01, dest_addr: 0x2D44, dest_endpoint: 0x01, profile: 0x0104, cluster: PowerConfiguration >, < ZCLMessageBody || < ZCLHeader || frame_ctrl: 0x00, seqno: 0x00, ZCLCommandId: 0x00 >, < ReadAttribute || AttributeId: 0x0021 > > >
2021-12-23T18:18:17.482101561+00:00 DEBUG Xiaomi Luminance Sensor BG4  Xiaomi Luminance Sensor device thread event handled
2021-12-23T18:18:18.686368228+00:00 TRACE Xiaomi Luminance Sensor BG4  Received event with handler capability
2021-12-23T18:18:18.695548561+00:00 INFO Xiaomi Luminance Sensor BG4  <ZigbeeDevice: 31c7f8fe-eaec-4ee5-b0af-8305aa42167e [0x2D44] (Xiaomi Luminance Sensor)> received command: {"command":"refresh","positional_args":[],"component":"main","args":[],"capability":"refresh"}
2021-12-23T18:18:18.710156895+00:00 TRACE Xiaomi Luminance Sensor BG4  Found CapabilityCommandDispatcher handler in xiaomi-illuminance
2021-12-23T18:18:18.779979895+00:00 INFO Xiaomi Luminance Sensor BG4  <ZigbeeDevice: 31c7f8fe-eaec-4ee5-b0af-8305aa42167e [0x2D44] (Xiaomi Luminance Sensor)> sending Zigbee message: < ZigbeeMessageTx || Uint16: 0x0000, < AddressHeader || src_addr: 0x0000, src_endpoint: 0x01, dest_addr: 0x2D44, dest_endpoint: 0x01, profile: 0x0104, cluster: PowerConfiguration >, < ZCLMessageBody || < ZCLHeader || frame_ctrl: 0x00, seqno: 0x00, ZCLCommandId: 0x00 >, < ReadAttribute || AttributeId: 0x0021 > > >
2021-12-23T18:18:18.802951895+00:00 DEBUG Xiaomi Luminance Sensor BG4  Xiaomi Luminance Sensor device thread event handled
2021-12-23T18:18:20.086645562+00:00 TRACE Xiaomi Luminance Sensor BG4  Received event with handler capability
2021-12-23T18:18:20.095734895+00:00 INFO Xiaomi Luminance Sensor BG4  <ZigbeeDevice: 31c7f8fe-eaec-4ee5-b0af-8305aa42167e [0x2D44] (Xiaomi Luminance Sensor)> received command: {"command":"refresh","positional_args":[],"component":"main","args":[],"capability":"refresh"}
2021-12-23T18:18:20.102024229+00:00 TRACE Xiaomi Luminance Sensor BG4  Found CapabilityCommandDispatcher handler in xiaomi-illuminance
2021-12-23T18:18:20.114818895+00:00 INFO Xiaomi Luminance Sensor BG4  <ZigbeeDevice: 31c7f8fe-eaec-4ee5-b0af-8305aa42167e [0x2D44] (Xiaomi Luminance Sensor)> sending Zigbee message: < ZigbeeMessageTx || Uint16: 0x0000, < AddressHeader || src_addr: 0x0000, src_endpoint: 0x01, dest_addr: 0x2D44, dest_endpoint: 0x01, profile: 0x0104, cluster: PowerConfiguration >, < ZCLMessageBody || < ZCLHeader || frame_ctrl: 0x00, seqno: 0x00, ZCLCommandId: 0x00 >, < ReadAttribute || AttributeId: 0x0021 > > >
2021-12-23T18:18:20.144039229+00:00 DEBUG Xiaomi Luminance Sensor BG4  Xiaomi Luminance Sensor device thread event handled
2021-12-23T18:18:21.206038563+00:00 TRACE Xiaomi Luminance Sensor BG4  Received event with handler capability
2021-12-23T18:18:21.226650563+00:00 INFO Xiaomi Luminance Sensor BG4  <ZigbeeDevice: 31c7f8fe-eaec-4ee5-b0af-8305aa42167e [0x2D44] (Xiaomi Luminance Sensor)> received command: {"command":"refresh","positional_args":[],"component":"main","args":[],"capability":"refresh"}
2021-12-23T18:18:21.240128229+00:00 TRACE Xiaomi Luminance Sensor BG4  Found CapabilityCommandDispatcher handler in xiaomi-illuminance
2021-12-23T18:18:21.247503896+00:00 INFO Xiaomi Luminance Sensor BG4  <ZigbeeDevice: 31c7f8fe-eaec-4ee5-b0af-8305aa42167e [0x2D44] (Xiaomi Luminance Sensor)> sending Zigbee message: < ZigbeeMessageTx || Uint16: 0x0000, < AddressHeader || src_addr: 0x0000, src_endpoint: 0x01, dest_addr: 0x2D44, dest_endpoint: 0x01, profile: 0x0104, cluster: PowerConfiguration >, < ZCLMessageBody || < ZCLHeader || frame_ctrl: 0x00, seqno: 0x00, ZCLCommandId: 0x00 >, < ReadAttribute || AttributeId: 0x0021 > > >
2021-12-23T18:18:21.282010229+00:00 DEBUG Xiaomi Luminance Sensor BG4  Xiaomi Luminance Sensor device thread event handled
2021-12-23T18:18:22.455956230+00:00 TRACE Xiaomi Luminance Sensor BG4  Received event with handler capability
2021-12-23T18:18:22.465580230+00:00 INFO Xiaomi Luminance Sensor BG4  <ZigbeeDevice: 31c7f8fe-eaec-4ee5-b0af-8305aa42167e [0x2D44] (Xiaomi Luminance Sensor)> received command: {"command":"refresh","positional_args":[],"component":"main","args":[],"capability":"refresh"}
2021-12-23T18:18:22.480126897+00:00 TRACE Xiaomi Luminance Sensor BG4  Found CapabilityCommandDispatcher handler in xiaomi-illuminance
2021-12-23T18:18:22.488972897+00:00 INFO Xiaomi Luminance Sensor BG4  <ZigbeeDevice: 31c7f8fe-eaec-4ee5-b0af-8305aa42167e [0x2D44] (Xiaomi Luminance Sensor)> sending Zigbee message: < ZigbeeMessageTx || Uint16: 0x0000, < AddressHeader || src_addr: 0x0000, src_endpoint: 0x01, dest_addr: 0x2D44, dest_endpoint: 0x01, profile: 0x0104, cluster: PowerConfiguration >, < ZCLMessageBody || < ZCLHeader || frame_ctrl: 0x00, seqno: 0x00, ZCLCommandId: 0x00 >, < ReadAttribute || AttributeId: 0x0021 > > >
2021-12-23T18:18:22.507515563+00:00 DEBUG Xiaomi Luminance Sensor BG4  Xiaomi Luminance Sensor device thread event handled

In fact, the configuration has not been executed, the lifecycle doConfigure has not been called and the configuration of the illuminance reports has not been sent.

Lifecycle Ini, added, driverSwitched and infoChanged have been executed, but doConfigure not

1 Like

Ahh I had made a silly typo in do_configure , I can now see a lux reading, which is also seen in the logs:

2021-12-23T18:57:44.516634937+00:00 TRACE Zigbee Illuminance Sensor  Received event with handler zigbee
2021-12-23T18:57:44.530170604+00:00 INFO Zigbee Illuminance Sensor  <ZigbeeDevice: 07fbf1e4-4594-49c1-9363-278151b4acd2 [0x7307] (Illuminance Sensor)> received Zigbee message: < ZigbeeMessageRx || type: 0x00, < AddressHeader || src_addr: 0x7307, src_endpoint: 0x01, dest_addr: 0x0000, dest_endpoint: 0x01, profile: 0x0104, cluster: IlluminanceMeasurement >, lqi: 0x80, rssi: -68, body_length: 0x0008, < ZCLMessageBody || < ZCLHeader || frame_ctrl: 0x18, seqno: 0x41, ZCLCommandId: 0x0A >, < ReportAttribute || < AttributeRecord || AttributeId: 0x0000, DataType: Uint16, MeasuredValue: 0x9B71 > > > >
2021-12-23T18:57:44.562262604+00:00 TRACE Zigbee Illuminance Sensor  Found ZigbeeMessageDispatcher handler in zigbee-illuminance
2021-12-23T18:57:44.569558937+00:00 INFO Zigbee Illuminance Sensor  Executing ZclClusterAttributeValueHandler: cluster: IlluminanceMeasurement, attribute: MeasuredValue
2021-12-23T18:57:44.578803604+00:00 INFO Zigbee Illuminance Sensor  <ZigbeeDevice: 07fbf1e4-4594-49c1-9363-278151b4acd2 [0x7307] (Illuminance Sensor)> emitting event: {"capability_id":"illuminanceMeasurement","state":{"value":9532},"attribute_id":"illuminance","component_id":"main"}
2021-12-23T18:57:44.609357937+00:00 DEBUG Zigbee Illuminance Sensor  Illuminance Sensor device thread event handled
2021-12-23T18:58:09.899131616+00:00 TRACE Zigbee Illuminance Sensor  Received event with handler zigbee health poll

I seem to be getting a warning for the battery readings though:

2021-12-23T18:46:50.663718353+00:00 INFO Zigbee Illuminance Sensor  <ZigbeeDevice: 07fbf1e4-4594-49c1-9363-278151b4acd2 [0x7307] (Illuminance Sensor)> received Zigbee message: < ZigbeeMessageRx || type: 0x00, < AddressHeader || src_addr: 0x7307, src_endpoint: 0x01, dest_addr: 0x0000, dest_endpoint: 0x01, profile: 0x0104, cluster: PowerConfiguration >, lqi: 0x80, rssi: -68, body_length: 0x0007, < ZCLMessageBody || < ZCLHeader || frame_ctrl: 0x18, seqno: 0x07, ZCLCommandId: 0x0A >, < ReportAttribute || < AttributeRecord || AttributeId: 0x0020, DataType: Uint8, BatteryVoltage: 0x1E > > > > 
2021-12-23T18:46:50.690086019+00:00 TRACE Zigbee Illuminance Sensor  Found ZigbeeMessageDispatcher handler in zigbee-illuminance
2021-12-23T18:46:50.695804019+00:00 INFO Zigbee Illuminance Sensor  Executing ZclClusterAttributeValueHandler: cluster: PowerConfiguration, attribute: BatteryVoltage
*2021-12-23T18:46:50.701975353+00:00 WARN Zigbee Illuminance Sensor  The device reported a voltage, but the driver was not configured to handle it.*

thank you for all of your help

1 Like

So now you receive the reports from Illuminance correctly, right? I see that the message received corresponds to a ReportAttribute.
About the battery report, did you register for the default handler of the battery? It seems there’s no handler for this specific cluster and attribute.
This registration is made with this line of the driver:

defaults.register_for_default_handlers(zigbee_driver_template, zigbee_driver_template.supported_capabilities)
1 Like

It seems that it is using the 0x0020 attribute to report the battery voltage.

It must be that it does not use the specific clusters of xiaomi.

I would remove xioami attr from the attr handlers and put a handler to handle the attr 0x0020 clusters.PowerConfiguration.attributes.BatteryVoltage.ID

I usually use the code that uses smartthings in its v4 multipurpose sensor drivers and it works fine.

This would be the code that I sent you from init.lua with the changes for the battery and removing the xiaomi_utils libraries

init .lua:

local capabilities = require "st.capabilities"
local ZigbeeDriver = require "st.zigbee"
local defaults = require "st.zigbee.defaults"
local constants = require "st.zigbee.constants"
local clusters = require "st.zigbee.zcl.clusters"
local device_management = require "st.zigbee.device_management"
--local xiaomi_utils = require "xiaomi_utils"

local function do_configure(self, device)
  -- configure Illuminance reports
  --Maxt time interval 600 sec
  local maxTime = 600
  -- Reportable change 5 lux
  local changeRep = math.floor(10000 * (math.log((5 + 1), 10)))
  print ("Illuminance maxTime y changeRep: ",maxTime, changeRep )
  device:send(device_management.build_bind_request(device, clusters.IlluminanceMeasurement.ID, self.environment_info.hub_zigbee_eui))
  device:send(clusters.IlluminanceMeasurement.attributes.MeasuredValue:configure_reporting(device, 60, maxTime, changeRep))
  device:configure()
end
---illuminance_measurement_defaults
local function illuminance_measurement_defaults(driver, device, value, zb_rx)
  --local lux_value = math.floor(math.pow(10, (value.value - 1) / 10000))  --- defualt librarie edge lua
  local lux_value = math.floor(10 ^ ((value.value - 1) / 10000))
  device:emit_event_for_endpoint(zb_rx.address_header.src_endpoint.value, capabilities.illuminanceMeasurement.illuminance(lux_value))
end

--- voltage battery handler
local utils = require "st.utils"
local battery = capabilities.battery
local battery_defaults = require "st.zigbee.defaults.battery_defaults"

local battery_handler = function(driver, device, value, zb_rx)
  local batteryMap = {[28] = 100, [27] = 100, [26] = 100, [25] = 90, [24] = 90, [23] = 70,
                    [22] = 70, [21] = 50, [20] = 50, [19] = 30, [18] = 30, [17] = 15, [16] = 1, [15] = 0}
  local minVolts = 15
  local maxVolts = 28

  value = utils.clamp_value(value.value, minVolts, maxVolts)

  device:emit_event(battery.battery(batteryMap[value]))
end

-----Driver template
local zigbee_illuminance_driver = {
  supported_capabilities = {
    capabilities.illuminanceMeasurement,
    capabilities.battery,
  },
  lifecycle_handlers = {
    doConfigure = do_configure,
    init = battery_defaults.build_linear_voltage_init(2.3, 3.0)
  },
  zigbee_handlers = {
    attr = {
      --[clusters.basic_id] = {
        --[0xFF02] = xiaomi_utils.battery_handler,
        --[0xFF01] = xiaomi_utils.battery_handler
      --},
      [clusters.PowerConfiguration.ID] = {
        [clusters.PowerConfiguration.attributes.BatteryVoltage.ID] = battery_handler
      },
      [clusters.IlluminanceMeasurement.ID] = {
        [clusters.IlluminanceMeasurement.attributes.MeasuredValue.ID] = illuminance_measurement_defaults
      }
    },
  },
    --sub_drivers = {
                --require("lumi-lux")
              --}
}

--------- driver run ------
defaults.register_for_default_handlers(zigbee_illuminance_driver, zigbee_illuminance_driver.supported_capabilities)
local driver = ZigbeeDriver("zigbee-illuminance", zigbee_illuminance_driver)
driver:run()

1 Like

The lux sensors (both Xiaomi and Aqara) are a ZigBee 3.0 certified device and do not use any Xiaomi specific clusters. The battery reports in voltage using the standard ZigBee cluster.

1 Like

Yes, I already saw it in the DTH, but since @Benjamin_Ginders, in his code posted set to handle it with the basic cluster and attribute 0xFF01, I took it for granted that it worked with that specific cluster.

It is already corrected in the code that I posted

1 Like

Not all icons have an active (“colored”) version, there’s already a request for the engineering team to provide more information about this in the Developers documentation.
Also, what provides the active or inactive state of the icon is the capability set in the Dashboard view. It must have the alternatives section with values of type active and inactive configured.
In numeric capabilities, it’s not suitable to configure alternatives because there’s a large number of possible values.
Some of the capabilities that can change the icon status are contactSensor, smokeDetector, switch and motionSensor.

1 Like

Thanks @Mariano_Colmenarejo I now have working battery an Lux values however I probably need to alter the reported levels to ensure they are correct to the battery used in the sensor.
Thank you for helping me to get this working, you have been a great help!

Next step is a configurable preference for what lux value should be the threshold for day/night or light/dark which can be mapped for automations… maybe even have the Icon change based on the same values if @nayelyz can confirm of this icon is responsive.

BTW when I click edit on the device I can see the inverted icon colors, so hopefully this can be mapped :grinning:

Main Icon
Main Icon

Edit Screen Icon

Illuminance driver screenshots:

Preferences

Lux reports (used a torch to get reports hence why the jump from 0 to x)

Main device view

1 Like

@Benjamin_Ginders

Care to post your working version, either as a channel or to GitHub?

It will need the Aqara fingerprint to work with the new version; the Mijia version is discontinued. The fingerprint for the new version is identical except the model number: lumi.sen_ill.agl01

Hi @mvevitsis I have closed my laptop for the night now (it’s 23:12 here) will run some further tests tomorrow and then post on my GitHub also on a public channel.

1 Like

You are welcome!

If you need it, I’ll give you the code that I use in infoChanged lifecycle to configure the maximum intervals and reportable change in preferences and the code to reconfigure the device when the value in preferences is changed.

Or you can also see it on my github for the temperature sensor and others.

https://github.com/Mariano-Github/Edge-Drivers-Beta

Does the formula for conversion to lux works well or does this device already send information in lux?

Hello Benjamin_Ginders
Please post your edge driver your channel please. I’d like to test and use it with my “lumi.sen_ill.mgl01” :slight_smile:
Dusan

Hi,

Please see below channel link for this driver:
https://api.smartthings.com/invite/d429zxAN0Plo

I have not had chance to fully test this yet so please do let me know if you face any issues

Hello,
Installed your driver and repaired the device. It took only 5sec to pair.
Lux measurement works fine ;):hugs::tumbler_glass:
Battery shows 100% but i dont care about batery info :face_with_hand_over_mouth:
If you need any future info about changes you will make just let me know.

Thank you!!!

They only report when the battery is low, there is no periodic reporting as far as I know.

@Benjamin_Ginders does this include fingerprints for both models?

Hi @mvevitsis yes this does include the fingerprint for both models which use the LUMI manufacturer tag.

The battery functionality is something I am still trying to figure out.

One way to test would be to power it using a lower voltage, say 2.5v and see if it reports something.
Either using a bench power supply or a drained battery.

It should start reporting at some point I just don’t know how low it has to be.

One thing that annoys me about lumi devices is that they only report voltage and not percentage. But at least they are using standard clusters now.