arachnetech / homebridge-mqttthing

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

RF Switch with just one RF Code #260

Open carlderdritte opened 4 years ago

carlderdritte commented 4 years ago

Hi, I have a RF switch I would like to use. I use a RF Bridge with Tasmota and it works fine with a few contact sensors with two rf codes...

It seems kinda simple to do but I can't figure it out myself. Anyone able to give me a helping hand?

arachnetech commented 4 years ago

Which accessory type would you like to use? Presumably Switch (https://github.com/arachnetech/homebridge-mqttthing/blob/master/docs/Accessories.md#switch)? Can you provide examples of the MQTT messages that you wish to send?

carlderdritte commented 4 years ago

Yes Switch would be the right thing. I have to admit I am far from knowing what Mqtt messages I want to send but what I can offer is that I want to use the rf switch to first switch a lamp on and than off. the problem I run in to is it just sends this one rf code and not two. So the rf code needs to be able to change the state of the switch no matter if its on or off. Does that makes sense somehow? I put in what I use for the other devices :

{
    "accessory": "mqttthing",
    "type": "contactSensor",
    "name": "Lounge",
    "url": "mqtt://127.0.0.1",
    "username": "home",
    "password": "XXXX",
    "caption": "",
    "topics": {
        "getContactSensorState": {
            "topic": "tele/sonoff_rf/RESULT",
            "apply": "return( ( JSON.parse(message).RfReceived.Data == '0XXX3' ) ? 1 : null || ( JSON.parse(message).RfReceived.Data == '0XXX9' ) ? 0 : null);"
        },
        "getStatusTampered": {
            "topic": "tele/sonoff_rf/RESULT",
            "apply": "return( ( JSON.parse(message).RfReceived.Data == 'tempered_code' ) ? 1 : null );"
        },
        "getStatusLowBattery": {
            "topic": "tele/sonoff_rf/RESULT",
            "apply": "return( ( JSON.parse(message).RfReceived.Data == 'battery_low_code' ) ? 1 : null );"
        }
    },
    "integerValue": true,
    "logMqtt": false
},

Thank you a lot for taking the time !

arachnetech commented 4 years ago

Thanks for the configuration. I'm hoping that these complicated-looking configurations can be simplified through the new json codec, but if that's working as-is there's little point changing it.

For your new switch, what MQTT messages do you need to publish to turn it on and off?

carlderdritte commented 4 years ago

if I press the switch I get the following in the console of the RF bridge 12:40:20 MQT: tele/sonoff_rf/RESULT = {"Time":"2020-05-14T12:40:20","RfReceived":{"Sync":10240,"Low":350,"High":1040,"Data":"3XXXX8","RfKey":"None"}}

and I want to use this switch to toggle a different wifi wall switch via home bridge/homekit