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

setActive, multiple commands #570

Closed tomlcooper closed 2 years ago

tomlcooper commented 2 years ago

I am using the valve accessory, which only has 'setActive' for turning the valve on and off. The problem is, I need to send a different command for on and off, such as:

ON: JSON.stringify({'cmd': 6, 'device_id': 'xxxxxxx', 'duration': 600})
OFF: JSON.stringify({'cmd': 7, 'device_id': 'xxxxxxx'})

The 'getActive' valves are true and false.

I thought I would be able to do this using an if function, but I do not know how to get whether it's an on or off command from the HomeKit switch to use in the if function.

Any help would be appreciated.

tomlcooper commented 2 years ago

I managed to work this out if (message == true) return JSON.stringify({'cmd': 6, 'device_id': 'xxxxxxx', 'duration': 600}); return JSON.stringify({'cmd': 7, 'device_id': 'xxxxxxx'})