Quirk for Zigbee smoke/CO detector "_TZE2841000000_6ycgarab"

Hello there

I thought I share the quirk for a Tuya Zigbee smoke and CO detector “TS0601” from “_TZE2841000000_6ycgarab”. No clue if the device is new, but I could not find an available quirk.

from zigpy.quirks.v2.homeassistant.binary_sensor import BinarySensorDeviceClass
import zigpy.types as t

from zhaquirks.tuya import TUYA_CLUSTER_ID
from zhaquirks.tuya.builder import TuyaQuirkBuilder

(
    TuyaQuirkBuilder("_TZE2841000000_6ycgarab", "TS0601")
    .tuya_dp_attribute(
        dp_id=1,
        attribute_name="smoke",
        type=t.Bool,
        converter=lambda x: x != 0,
    )
    .binary_sensor(
        attribute_name="smoke",
        cluster_id=TUYA_CLUSTER_ID,
        device_class=BinarySensorDeviceClass.SMOKE,
        translation_key="smoke",
        fallback_name="Smoke",
    )
    .tuya_dp_attribute(
        dp_id=18,
        attribute_name="carbon_monoxide",
        type=t.Bool,
        converter=lambda x: x != 0,
    )
    .binary_sensor(
        attribute_name="carbon_monoxide",
        cluster_id=TUYA_CLUSTER_ID,
        device_class=BinarySensorDeviceClass.CO,
        translation_key="carbon_monoxide",
        fallback_name="Carbon monoxide",
    )
    .tuya_switch(
        dp_id=16,
        attribute_name="silence_alarm",
        translation_key="silence_alarm",
        fallback_name="Silence alarm",
    )
    .tuya_switch(
        dp_id=17,
        attribute_name="alarm_switch",
        translation_key="alarm_switch",
        fallback_name="Alarm switch",
    )
    .skip_configuration()
    .add_to_registry()
)

Please see this as a draft, since I don’t know much about this stuff. I could not get the battery entity working, I seems the state is reported but does not find its way to the entity. So I had to use an automation as workaround:

ZHA toolkit reads the battery and sets the value in an input_number:

alias: Smoke detector - read battery
triggers:
- trigger: time_pattern
 hours: /6
actions:
- action: zha_toolkit.execute
 data:
   command: attr_read
   ieee: sensor.smoke_detector_lqi
   cluster: 1
   attribute: 33
   tries: 5
 response_variable: battery_result
- action: input_number.set_value
 target:
   entity_id: input_number.smoke_detector_battery
 data:
   value: '{{ (battery_result.result_read[0][33] | int) / 2 }}'
mode: single

This helper/input_number serves the Battery Notes integration as template:

{{ states('input_number.rauchmelder_schlafzimmer_batterie') }}

Works for me, but I am sure somebody out there has got a better idea.