0x5e / homebridge-tuya-platform

Make homebridge-tuya-platform great again.
MIT License
206 stars 58 forks source link

8-in-1 Air Quality Sensor not recognized correctly #459

Open Jozer99 opened 2 months ago

Jozer99 commented 2 months ago

Prerequisite

Cache

Version

1.7.0-beta.53

Device Infomation JSON File

[
  {
    "active_time": 1714517960,
    "biz_type": 0,
    "category": "co2bj",
    "create_time": 1714517960,
    "icon": "smart/icon/bay16345249392367NnR/c945428435e0f2cc5d8e17b8cdfbc47b.png",
    "id": "XXX",
    "ip": "XXX",
    "lat": "XXX",
    "local_key": "XXX",
    "lon": "XXX",
    "model": "",
    "name": "XXX",
    "online": true,
    "owner_id": "XXX",
    "product_id": "yrr3eiyiacm31ski",
    "product_name": "AIR_DETECTOR ",
    "status": [
      {
        "code": "alarm_bright",
        "value": 0
      },
      {
        "code": "alarm_switch",
        "value": true
      },
      {
        "code": "alarm_time",
        "value": 1
      },
      {
        "code": "alarm_volume",
        "value": "low"
      },
      {
        "code": "battery_percentage",
        "value": 100
      },
      {
        "code": "ch2o_value",
        "value": 1
      },
      {
        "code": "co2_state",
        "value": "normal"
      },
      {
        "code": "co2_value",
        "value": 714
      },
      {
        "code": "humidity_value",
        "value": 48
      },
      {
        "code": "pm25_value",
        "value": 4
      },
      {
        "code": "temp_current",
        "value": 19
      },
      {
        "code": "voc_value",
        "value": 1
      }
    ],
    "sub": false,
    "time_zone": "XXX",
    "uid": "XXX",
    "update_time": 1714518069,
    "uuid": "XXX",
    "schema": [
      {
        "code": "alarm_bright",
        "mode": "rw",
        "type": "Integer",
        "property": {
          "unit": "%",
          "min": 0,
          "max": 100,
          "scale": 0,
          "step": 1
        }
      },
      {
        "code": "alarm_switch",
        "mode": "rw",
        "type": "Boolean",
        "property": {}
      },
      {
        "code": "alarm_time",
        "mode": "rw",
        "type": "Integer",
        "property": {
          "unit": "s",
          "min": 1,
          "max": 60,
          "scale": 0,
          "step": 1
        }
      },
      {
        "code": "alarm_volume",
        "mode": "rw",
        "type": "Enum",
        "property": {
          "range": [
            "low",
            "middle",
            "high",
            "mute"
          ]
        }
      },
      {
        "code": "battery_percentage",
        "mode": "ro",
        "type": "Integer",
        "property": {
          "unit": "%",
          "min": 0,
          "max": 100,
          "scale": 0,
          "step": 1
        }
      },
      {
        "code": "ch2o_value",
        "mode": "ro",
        "type": "Integer",
        "property": {
          "unit": "mg/m3",
          "min": 0,
          "max": 9999,
          "scale": 3,
          "step": 1
        }
      },
      {
        "code": "co2_state",
        "mode": "ro",
        "type": "Enum",
        "property": {
          "range": [
            "alarm",
            "normal"
          ]
        }
      },
      {
        "code": "co2_value",
        "mode": "ro",
        "type": "Integer",
        "property": {
          "unit": "ppm",
          "min": 0,
          "max": 5000,
          "scale": 0,
          "step": 1
        }
      },
      {
        "code": "humidity_value",
        "mode": "ro",
        "type": "Integer",
        "property": {
          "unit": "%",
          "min": 0,
          "max": 100,
          "scale": 0,
          "step": 1
        }
      },
      {
        "code": "pm25_value",
        "mode": "ro",
        "type": "Integer",
        "property": {
          "unit": "ug/m3",
          "min": 0,
          "max": 1000,
          "scale": 0,
          "step": 1
        }
      },
      {
        "code": "temp_current",
        "mode": "ro",
        "type": "Integer",
        "property": {
          "unit": "℃",
          "min": -9,
          "max": 199,
          "scale": 0,
          "step": 1
        }
      },
      {
        "code": "voc_value",
        "mode": "ro",
        "type": "Integer",
        "property": {
          "unit": "mg/m3",
          "min": 0,
          "max": 9999,
          "scale": 3,
          "step": 1
        }
      }
    ]
  }
]

Device Control Mode

Standard Instruction

Logs

[01/05/2024, 23:30:20] Homebridge v1.8.1 (HAP v0.12.0) (Homebridge XXX) is running on port 51090.
[01/05/2024, 23:30:21] [Tuya] Start MQTT connection.
[01/05/2024, 23:30:21] [Tuya] Fetching home list.
[01/05/2024, 23:30:22] [Tuya] Got home_id=XXX, name=XXX ..
[01/05/2024, 23:30:22] [Tuya] Fetching device list.
[01/05/2024, 23:30:23] [Tuya] Fetching scene list.
[01/05/2024, 23:30:23] [Tuya] Got 1 device(s) and scene(s).
[01/05/2024, 23:30:23] [Tuya] Device list saved at /var/lib/homebridge/persist/XXX.json
[01/05/2024, 23:30:23] [Tuya] Restoring existing accessory from cache: Downstairs Air Quality

Other Infomations

Purchased 8-in-1 air quality sensor from here - https://www.aliexpress.us/item/3256805338878009.html

Installed Tuya plugin per your directions and created a Tuya API account.

The device shows up in Homebridge and HomeKit as only two sensors: battery level and CO2 level. The other sensors (PM2.5, TVOC, HCHO, temperature, humidity) do not show up. From the device information json file it seems like these properties are defined but are not being mapped by the plugin as HomeKit sensors.