ptvoinfo/zigbee-configurable-firmware

Autogenerated ZHA quirk needs modification for IKEA Vindriktning Air Quality Sensor

bullar opened this issue · 2 comments

When using the PM1006 setup (for IKEA Vindriktning Air Quality Sensor) as shown:
Screenshot 2024-06-17 at 17 31 51

the autogenerated quirk for ZHA needs the following modification to operate correctly
(PTVO Firmware configuration 1.9.0.21 (Firmware: 2024-05-23)):

- is the modified version

--- /Volumes/config/custom_zha_quirks/dirb_particle_1.py
+++ /Users/<hidden>/Desktop/dirb_particle_1_orig.py
@@ -6,14 +6,12 @@
 from zigpy.quirks import CustomCluster, CustomDevice
 from zhaquirks import Bus, LocalDataCluster
 from zigpy.zcl.clusters.homeautomation import Diagnostic
-from zigpy.zcl.clusters.general import OnOff
 from zigpy.zcl.clusters.general import Basic
 from zigpy.zcl.clusters.general import MultistateValue
 from zigpy.zcl.clusters.general import AnalogInput
 from zigpy.zcl.clusters.general import MultistateInput
 from zigpy.zcl.clusters.general import OnOffConfiguration
-from zigpy.zcl.clusters.measurement import TemperatureMeasurement
-from zigpy.zcl.clusters.measurement import RelativeHumidity
+
 
 from zhaquirks.const import (
     DEVICE_TYPE,
@@ -283,17 +281,34 @@
     )
     class PtvoAnalogInputSensorEp1Attr0(Sensor):
         _attr_name = "MC PM2.5 1"
-        _attribute_name = "mcpm25"
-        _attr_translation_key = "mcpm25"
-        _unique_id_suffix = "mcpm25_ep1"
+        _attribute_name = "mcpm2"
+        _attr_translation_key = "mcpm2"
+        _unique_id_suffix = "mcpm2_ep1"
         _attr_icon = "mdi:air-filter"
         _attr_device_class = SensorDeviceClass.PM25
         _attr_state_class = None
-        _attr_native_unit_of_measurement = "µg/m³"
+        _attr_native_unit_of_measurement = "ug/m3"
+
+    @MULTI_MATCH(
+        cluster_handler_names= CLUSTER_NAME_PTVO_ANALOG_INPUT_VALUE2 + "1",
+        models={PTVO_MODEL_ID},
+    )
+    class PtvoAnalogInputSensorEp1Attr1(Sensor):
+        _attr_name = "Number Conc. PM0.5 1"
+        _attribute_name = "ncpm0"
+        _attr_translation_key = "ncpm0"
+        _unique_id_suffix = "ncpm0_ep1"
+        _attr_icon = "mdi:air-filter"
+        _attr_device_class = None
+        _attr_state_class = None
+        _attr_native_unit_of_measurement = "#/cm3"
 
     attributes = {
-        0x0000: ("mcpm25", t.Single, True),
+        0x0000: ("mcpm2", t.Single, True),
+        0x0001: ("ncpm0", t.Single, True),
     }
+
+
 
 
 class ptvo_custom_device(CustomDevice):
@@ -312,7 +327,7 @@
             1: {
                 PROFILE_ID: zha.PROFILE_ID,
                 DEVICE_TYPE: PTVO_DEVICE_TYPE_GENERIC,
-                INPUT_CLUSTERS: [Basic.cluster_id, MultistateValue.cluster_id, PtvoAnalogInput.cluster_id, OnOffConfiguration.cluster_id, TemperatureMeasurement.cluster_id, RelativeHumidity.cluster_id],
+                INPUT_CLUSTERS: [Basic.cluster_id, MultistateValue.cluster_id, PtvoAnalogInput.cluster_id, OnOffConfiguration.cluster_id],
                 OUTPUT_CLUSTERS: [Basic.cluster_id, PtvoMultistateInput.cluster_id, OnOff.cluster_id],
             }
         },
@@ -325,7 +340,7 @@
                 PROFILE_ID: zha.PROFILE_ID,
                 DEVICE_TYPE: PTVO_DEVICE_TYPE_GENERIC,
                 INPUT_CLUSTERS: [Basic.cluster_id, PtvoAnalogInput, PtvoAnalogInputEp1, PtvoMultistateInput, OnOffConfiguration.cluster_id],
-                OUTPUT_CLUSTERS: [Basic.cluster_id, MultistateInput.cluster_id, OnOff.cluster_id],
+                OUTPUT_CLUSTERS: [Basic.cluster_id, OnOff.cluster_id],
             }
         },
     }

@bullar Could you please clarify the purport of renaming mcpm2 to mcpm25?

I got an error from ZHA when integrating the device with the original quirk claiming ‚mcpm25 couldn‘t be found‘. Therefore I renamed all and then the error was gone. Unfortunately I don‘t have this error message stored. Let me know if I should reproduce the error again for more details…