0x5e / homebridge-tuya-platform

Make homebridge-tuya-platform great again.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support for amaran SMC5

m1guelpf opened this issue · comments

Prerequisite

  • Yes, I've read the readme completely.

Cache

  • Yes, I've cleaned accessory cache and the issue still exists.

Version

v1.7.0-beta.52

Device Infomation JSON File

[
  {
    "active_time": 1693099766,
    "biz_type": 0,
    "category": "fwd",
    "create_time": 1693099766,
    "icon": "smart/icon/bay16484395351801A4a/5977cd0b9585880726fc28ad5848fdbd.png",
    "id": "REDACTED",
    "ip": "REDACTED",
    "lat": "REDACTED",
    "local_key": "REDACTED",
    "lon": "REDACTED",
    "model": "amaran SM5c",
    "name": "amaran SM5c",
    "online": true,
    "owner_id": "164657934",
    "product_id": "mqlj80ixxdjzsndz",
    "product_name": "amaran SM5c",
    "status": [
      {
        "code": "bright_value",
        "value": 40
      },
      {
        "code": "colour_data",
        "value": "{\"h\":300,\"s\":1000,\"v\":10}"
      },
      {
        "code": "switch_led",
        "value": true
      },
      {
        "code": "temp_value",
        "value": 742
      },
      {
        "code": "work_mode",
        "value": "colour"
      }
    ],
    "sub": false,
    "time_zone": "+01:00",
    "uid": "eu16930997149886DZuY",
    "update_time": 1704938900,
    "uuid": "4bb2bd62587e05b9",
    "schema": [
      {
        "code": "bright_value",
        "mode": "rw",
        "type": "Integer",
        "property": {
          "min": 10,
          "max": 1000,
          "scale": 0,
          "step": 1
        }
      },
      {
        "code": "colour_data",
        "mode": "rw",
        "type": "Json",
        "property": {}
      },
      {
        "code": "switch_led",
        "mode": "rw",
        "type": "Boolean",
        "property": {}
      },
      {
        "code": "temp_value",
        "mode": "rw",
        "type": "Integer",
        "property": {
          "min": 0,
          "max": 1000,
          "scale": 0,
          "step": 1
        }
      },
      {
        "code": "work_mode",
        "mode": "rw",
        "type": "Enum",
        "property": {
          "range": [
            "white",
            "colour",
            "scene",
            "music"
          ]
        }
      }
    ]
  }

Device Control Mode

Standard Instruction

Logs

[1/11/2024, 2:50:16 AM] Homebridge v1.7.0 (HAP v0.11.1) (Homebridge 32C8) is running on port 51212.
[1/11/2024, 2:50:16 AM] [Tuya] Start MQTT connection.
[1/11/2024, 2:50:16 AM] [Tuya] Fetching home list.
[1/11/2024, 2:50:16 AM] [Tuya] Got home_id=164657934, name=My Home ..
[1/11/2024, 2:50:16 AM] [Tuya] Fetching device list.
[1/11/2024, 2:50:17 AM] [Tuya] Fetching scene list.
[1/11/2024, 2:50:17 AM] [Tuya] Got 1 device(s) and scene(s).
[1/11/2024, 2:50:17 AM] [Tuya] Device list saved at /var/lib/homebridge/persist/TuyaDeviceList.eu16930997149886DZuY.json
[1/11/2024, 2:50:17 AM] [Tuya] Restoring existing accessory from cache: amaran SM5c
[1/11/2024, 2:50:17 AM] [Tuya] [amaran SM5c] Light type: CW
[1/11/2024, 2:50:17 AM] [Tuya] [amaran SM5c] Adaptive Lighting disabled.

Other Infomations

The LED strip is RGB, but gets displayed as CW

@0x5e Seems like this happens because colour_data in the schema is an empty array and the data is passed as escaped JSON. What would be the best way to add support for this?

@m1guelpf Try override empty schema to {"h":{"min":1,"scale":0,"unit":"","max":360,"step":1},"s":{"min":1,"scale":0,"unit":"","max":255,"step":1},"v":{"min":1,"scale":0,"unit":"","max":255,"step":1}}:

There's so many products are wrong configured on server side so I don't have a better solution, you can modify the value if this range may not fit yours.

{
  "options": {
    // ...
    "deviceOverrides": [{
      "id": "your_device_id",
      "schema": [{
        "code": "colour_data",
        "property": {
          "h": {
            "min": 1,
            "scale": 0,
            "unit": "",
            "max": 360,
            "step": 1
          },
          "s": {
            "min": 1,
            "scale": 0,
            "unit": "",
            "max": 255,
            "step": 1
          },
          "v": {
            "min": 1,
            "scale": 0,
            "unit": "",
            "max": 255,
            "step": 1
          }
        }
      }]
    }]
  }
}