arachnetech / homebridge-mqttthing

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

Possibility to invert dimmer values #645

Closed raddi closed 8 months ago

raddi commented 9 months ago

Hi, is there a way to invert values from 0 to 100?

I have a window covering accessory with the following config:

"accessory": "mqttthing", "type": "windowCovering", "name": "Vorhang AZ", "url": "xxx", "username": "xxx", "password": "xxx", "topics": { "setTargetPosition": "cmnd/Arbeitszimmer_Vorhang/Dimmer", "getCurrentPosition": { "topic": "stat/Arbeitszimmer_Vorhang/RESULT", "apply": "return JSON.parse(message).Dimmer;" } }

The problem is, that in the Home App opening and closing is reversed, to when i tell Siri to open the Curtain, it closes it (or does nothing, as it is already closed).

Thanks! :)

raddi commented 8 months ago

For anyone interested, i solved it using this workaround:

"topics": { "setTargetPosition": { "topic": "cmnd/Vorhang/Dimmer", "apply": "return 100-message;" }, "getCurrentPosition": { "topic": "stat/Vorhang/RESULT", "apply": "return 100-JSON.parse(message).Dimmer;" } }