arachnetech / homebridge-mqttthing

A plugin for Homebridge allowing the integration of many different accessory types using MQTT.
Apache License 2.0
466 stars 104 forks source link

Manual press doesn't update state #624

Open lucaesse opened 1 year ago

lucaesse commented 1 year ago

Hi, I have this switch https://www.zigbee2mqtt.io/devices/TS0012.html#tuya-ts0012. I can control it with different payloads for state_left and state_right but if I manually press the switch the state is not updated in the home app. How can I update it?

Here is my config:

{ "type": "switch", "name": "Bagno", "url": "mqtt://192.168.3.8:1883", "topics": { "getOn": "zigbee2mqtt/Bagno-Camera/get", "setOn": "zigbee2mqtt/Bagno-Camera/set" }, "onValue": "{\"state_right\": \"ON\"}", "offValue": "{\"state_right\": \"OFF\"}", "history": false, "manufacturer": "TuYa", "model": "TS0012", "serialNumber": "TUYA-TS0012", "accessory": "mqttthing" }, { "type": "switch", "name": "Camera", "url": "mqtt://192.168.3.8:1883", "topics": { "getOn": "zigbee2mqtt/Bagno-Camera/get", "setOn": "zigbee2mqtt/Bagno-Camera/set" }, "onValue": "{\"state_left\": \"ON\"}", "offValue": "{\"state_left\": \"OFF\"}", "history": false, "manufacturer": "TuYa", "model": "TS0012", "serialNumber": "TUYA-TS0012", "accessory": "mqttthing" }

ProKtorOne commented 1 year ago

My working config:

     {
            "accessory": "mqttthing",
            "type": "custom",
            "name": "Cabinet Switch",
            "services": [
                {
                    "type": "switch",
                    "name": "Switch Left",
                    "topics": {
                        "setOn": "zigbee2mqtt/0xa4c13849111f9a87/left/set",
                        "getOn": {
                            "topic": "zigbee2mqtt/0xa4c13849111f9a87",
                            "apply": "return JSON.parse(message).state_left;"
                        }
                    },
                    "onValue": "ON",
                    "offValue": "OFF"
                },
                {
                    "type": "switch",
                    "name": "Switch Right",
                    "topics": {
                        "setOn": "zigbee2mqtt/0xa4c13849111f9a87/right/set",
                        "getOn": {
                            "topic": "zigbee2mqtt/0xa4c13849111f9a87",
                            "apply": "return JSON.parse(message).state_right;"
                        }
                    },
                    "onValue": "ON",
                    "offValue": "OFF"
                }
            ]
        }
lucaesse commented 1 year ago

Thank you, I finally solved with this config:

   {
        "type": "lightbulb-OnOff",
        "name": "Bagno",
        "url": "mqtt://192.168.3.8:1883",
        "mqttOptions": {
            "keepalive": 30
        },
        "topics": {
            "getOn": {
                "topic": "zigbee2mqtt/Bagno-Camera",
                "apply": "return JSON.parse(message).state_right"
            },
            "setOn": "zigbee2mqtt/Bagno-Camera/right/set"
        },
        "onValue": "ON",
        "offValue": "OFF",
        "manufacturer": "TuYa",
        "model": "TS0012",
        "serialNumber": "TUYA-TS0012",
        "accessory": "mqttthing"
    },
    {
        "type": "lightbulb-OnOff",
        "name": "Camera",
        "url": "mqtt://192.168.3.8:1883",
        "mqttOptions": {
            "keepalive": 30
        },
        "topics": {
            "getOn": {
                "topic": "zigbee2mqtt/Bagno-Camera",
                "apply": "return JSON.parse(message).state_left"
            },
            "setOn": "zigbee2mqtt/Bagno-Camera/left/set"
        },
        "onValue": "ON",
        "offValue": "OFF",
        "manufacturer": "TuYa",
        "model": "TS0012",
        "serialNumber": "TUYA-TS0012",
        "accessory": "mqttthing"
    }