Phoscon Hive no Battery Status

I have 4 Phoscon Hive Battery lights on my Zigbee ZHA network.

Hive Overview (phoscon.de)

While I can control the lights without any issues and the devices are running the latest firmware, the battery status does not display.

However, I can read the battery status using the Cluster command and get a correct value from 0 to 200 for battery_percentage_remaining (id: 0x0021).
Interestingly, the lights are showing as main-powered instead of battery-powered.

Does anyone have any ideas on how to solve this issue?

Device Signature:

{
  "node_descriptor": "NodeDescriptor(logical_type=<LogicalType.EndDevice: 2>, complex_descriptor_available=0, user_descriptor_available=0, reserved=0, aps_flags=0, frequency_band=<FrequencyBand.Freq2400MHz: 8>, mac_capability_flags=<MACCapabilityFlags.MainsPowered|RxOnWhenIdle|AllocateAddress: 140>, manufacturer_code=4405, maximum_buffer_size=82, maximum_incoming_transfer_size=82, server_mask=11264, maximum_outgoing_transfer_size=82, descriptor_capability_field=<DescriptorCapability.NONE: 0>, *allocate_address=True, *is_alternate_pan_coordinator=False, *is_coordinator=False, *is_end_device=True, *is_full_function_device=False, *is_mains_powered=True, *is_receiver_on_when_idle=True, *is_router=False, *is_security_capable=False)",
  "endpoints": {
    "1": {
      "profile_id": "0x0104",
      "device_type": "0x010d",
      "input_clusters": [
        "0x0000",
        "0x0001",
        "0x0003",
        "0x0004",
        "0x0005",
        "0x0006",
        "0x0008",
        "0x0300"
      ],
      "output_clusters": [
        "0x0019"
      ]
    },
    "242": {
      "profile_id": "0xa1e0",
      "device_type": "0x0061",
      "input_clusters": [],
      "output_clusters": [
        "0x0021"
      ]
    }
  },
  "manufacturer": "Phoscon",
  "model": "Hive",
  "class": "zigpy.device.Device"
}

Hi Alex,

I also couldn’t create a sensor with the battery value of the hive via ZHA.
Seems, the function zha.read_zigbee_cluster_attribute isn’t implemented yet (see also topics here in the forum and on Github)

A possible solution is to install the HACS-integration zha-toolkit with its function zha_toolkit.attr_read.

An automation reads the battery level periodically, writes the value into a helper (input_number), which is used as base for the battery-sensor (helper/template-sensor):

  • Add helper “number” (range 0-200): input_number.hive_battery_measure
  • Add helper “template” (sensor): sensor.hive_battery
    with state template:
{{ (states('input_number.hive_battery_measure') | int / 2 ) | round(0) }}
  • Add automation:
alias: Hive Battery
description: ""
trigger:
  - platform: time_pattern
    hours: /1
condition:
  - alias: Test if available
    condition: not
    conditions:
      - condition: or
        conditions:
          - condition: state
            entity_id: light.hive
            state: unknown
          - condition: state
            entity_id: light.hive
            state: unavailable
action:
  - service: zha_toolkit.attr_read
    data:
      ieee: light.hive
      endpoint: 1
      cluster: 1
      attribute: 33
      state_id: input_number.hive_battery_measure
mode: single

The automation reads the battery value once an hour, what seems enough for me and doesn’t drain the battery too much. To prevent errors, a condition checks whether the lamp is (not) available. The attribute 33 is the decimal equivalent for hex 0x0021, the id of Hives cluster attribute battery_percentage_remaining.
In the template, the measured battery value is converted into an integer percentage value (division by 2).
Apparently the battery level changes in steps of 20, the sensor accordingly by 10%.

1 Like

Thanks for your feedback … will directly try.

Hello 7knips,

thanks your solution is working. I have now all the battery states for my hive lamps.
Grate workaround and solution!

Currently I am in contact with phoscon to get this topic solved without the workaround.
I keep you informend.

Thanks again
:slight_smile:

Here the forum discussion with Phoscon

Hive no battery status - Dresden-Elektronik Hardware - deCONZ Community (phoscon.de)

Is it possible to over write the MACCapabilityFlags with a device spezific quirk?

Solved the topic by digging into custom quirks.
My HIVEs have now a battery status.

Oh, wow - nice work!
Seems to be a solution without extra stuff like zha-toolkit.

How did you built this custom quirk, and where is it stored to be available in home assistant?
Did you publish it anywhere, e.g. on https://github.com/zigpy/zha-device-handlers

Thanks for “digging into”