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

Carbon Dioxide Treshold Value conversion #583

Closed chalojak closed 1 year ago

chalojak commented 1 year ago

Hello, thanks for the great plugin. Could you please help me with the syntax? My Carbon Dioxide sensor only returns a numeric level value. I am trying to convert it to Homekit values (ABNORMAL/NORMAL) by a setting a condition with a treshold to use the "detected" state, but apparently, my syntax is not correct:

"topics": { "getCarbonDioxideDetected": { "topic": "tele/tasmota/SENSOR$.T67XX.CarbonDioxide", "apply": "return if (message > 1000) {return 'ABNORMAL';} else {return 'NORMAL';};" }, "getCarbonDioxideLevel": "tele/tasmota/SENSOR$.T67XX.CarbonDioxide" },

Many thanks, Jakub

chalojak commented 1 year ago

resolved - corrected syntax to: "apply": "if (message > 1000) {return 'ABNORMAL';} else {return 'NORMAL';};"