Control a Sonoff Switch with Temperature and Date

Hi,

I´m new to Node Red.
Have installed it on Home Assistant.
Can someone please explain how I control a Sonoff switch depending on date and temperature?
For Example:
Monday - Friday 06:00 - 18:00 and Temperatur (an Aqara Sensor) lower than 20.5 = Switch On
Else Switch off

Hi, @mimk97, and welcome to the forum.

If you already can control the Sonoff from Node-RED, you can get the timed on/off commands you need from a scheduling node such as bigtimer, schedex or cronplus. (A search of the flow library for 'timer' will give you more options.)

The most efficient way to handle the temperature condition is probably to read the sensor only when an "On" message arrives from the timer, and either pass or ignore the message depending on the temperature.

If you start developing a flow and run into difficulties, you can post the flow here and people will be happy to give more specific advice.

Thanks.
but which node can I use to passthrough the message depending on the temperature?

You have several options here. The switch, function, and gate ( node-red-contrib-simple-gate) nodes can all be used for this. A lot depends on whether the temperature is available at all times (for example, in a flow or global variable) or whether it is read on demand. In the second case, you might need to use the join node to combine the temperature and timer messages into a single message. You should look at the Flow Control section of the NR cookbook for ideas.

Thanks in Advance.
Will try :slight_smile:

I got it work.
But the Switch turn on every few seconds (if switch is on) and relay also make a noise
what´s wrong?

[{"id":"287145b1.ace60a","type":"tab","label":"Heizung","disabled":false,"info":""},{"id":"3c7fac8a.06c4a4","type":"BooleanLogicUltimate","z":"287145b1.ace60a","name":"","filtertrue":"both","persist":true,"sInitializeWith":"WaitForPayload","triggertopic":"trigger","outputtriggeredby":"all","inputCount":2,"topic":"result","x":440,"y":120,"wires":[["c54e5bbb.8e18c8"],[],[]]},{"id":"faa6bbf2.dc0bc8","type":"server-state-changed","z":"287145b1.ace60a","name":"Temp Küche","server":"f1b76942.37d308","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.aqara_sensor_kueche_3","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":70,"y":120,"wires":[["7de7ffcc.23ebc"]]},{"id":"892eb83f.50bda8","type":"bigtimer","z":"287145b1.ace60a","outtopic":"","outpayload1":"true","outpayload2":"false","name":"Wochentag und Zeit","comment":"","lat":"0","lon":"0","starttime":"360","endtime":"1080","starttime2":0,"endtime2":0,"startoff":0,"endoff":0,"startoff2":0,"endoff2":0,"offs":0,"outtext1":"","outtext2":"","timeout":1440,"sun":false,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"jan":true,"feb":true,"mar":true,"apr":true,"may":true,"jun":true,"jul":true,"aug":true,"sep":true,"oct":true,"nov":true,"dec":true,"day1":0,"month1":0,"day2":0,"month2":0,"day3":0,"month3":0,"day4":0,"month4":0,"day5":0,"month5":0,"day6":0,"month6":0,"d1":0,"w1":0,"d2":0,"w2":0,"d3":0,"w3":0,"d4":0,"w4":0,"d5":0,"w5":0,"d6":0,"w6":0,"xday1":0,"xmonth1":0,"xday2":0,"xmonth2":0,"xday3":0,"xmonth3":0,"xday4":0,"xmonth4":0,"xday5":0,"xmonth5":0,"xday6":0,"xmonth6":0,"xd1":0,"xw1":0,"xd2":0,"xw2":0,"xd3":0,"xw3":0,"xd4":0,"xw4":0,"xd5":0,"xw5":0,"xd6":0,"xw6":0,"suspend":false,"random":false,"repeat":true,"atstart":true,"odd":false,"even":false,"x":100,"y":260,"wires":[["3c7fac8a.06c4a4","f8a72dd0.d2348"],[],[]]},{"id":"7de7ffcc.23ebc","type":"combine-bangbang","z":"287145b1.ace60a","upper":"20.5","lower":"20.4","invert":true,"name":"Soll Temp Küche","x":250,"y":120,"wires":[["3c7fac8a.06c4a4"]]},{"id":"c54e5bbb.8e18c8","type":"switch","z":"287145b1.ace60a","name":"Steuerung Küche","property":"payload","propertyType":"msg","rules":[{"t":"false"},{"t":"true"}],"checkall":"false","repair":false,"outputs":2,"x":630,"y":140,"wires":[["f6fe72f7.b656c","98e403aa.8e3b2"],["5deb1988.605738","7fe96a81.461834"]]},{"id":"5deb1988.605738","type":"api-call-service","z":"287145b1.ace60a","name":"Hzg Aktor Küche AN","server":"f1b76942.37d308","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.fbh_switch","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":860,"y":160,"wires":[[]]},{"id":"f6fe72f7.b656c","type":"api-call-service","z":"287145b1.ace60a","name":"Hzg Aktor Küche AUS","server":"f1b76942.37d308","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.fbh_switch","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":860,"y":100,"wires":[[]]},{"id":"7fe96a81.461834","type":"api-call-service","z":"287145b1.ace60a","name":"Hzg Aktor Pumpe AN","server":"f1b76942.37d308","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.fbh_switch_3","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":860,"y":240,"wires":[[]]},{"id":"98e403aa.8e3b2","type":"api-call-service","z":"287145b1.ace60a","name":"Hzg Aktor Pumpe AUS","server":"f1b76942.37d308","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.fbh_switch_3","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":860,"y":300,"wires":[[]]},{"id":"a7e5bb73.5a7a28","type":"server-state-changed","z":"287145b1.ace60a","name":"Temp Laden","server":"f1b76942.37d308","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.aqara_sensor_laden","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":70,"y":420,"wires":[["349d4391.affd9c"]]},{"id":"349d4391.affd9c","type":"combine-bangbang","z":"287145b1.ace60a","upper":"20.5","lower":"20.4","invert":true,"name":"Soll Temp Laden","x":250,"y":420,"wires":[["f8a72dd0.d2348"]]},{"id":"f8a72dd0.d2348","type":"BooleanLogicUltimate","z":"287145b1.ace60a","name":"","filtertrue":"both","persist":true,"sInitializeWith":"WaitForPayload","triggertopic":"trigger","outputtriggeredby":"all","inputCount":2,"topic":"result","x":440,"y":420,"wires":[["f2ce211f.91b9c"],[],[]]},{"id":"f2ce211f.91b9c","type":"switch","z":"287145b1.ace60a","name":"Steuerung Laden","property":"payload","propertyType":"msg","rules":[{"t":"false"},{"t":"true"}],"checkall":"false","repair":false,"outputs":2,"x":650,"y":420,"wires":[["98e403aa.8e3b2","a43476ac.0b4538"],["7fe96a81.461834","b339bf25.e8ea9"]]},{"id":"a43476ac.0b4538","type":"api-call-service","z":"287145b1.ace60a","name":"Hzg Aktor Laden AUS","server":"f1b76942.37d308","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.fbh_switch_2","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":900,"y":400,"wires":[[]]},{"id":"b339bf25.e8ea9","type":"api-call-service","z":"287145b1.ace60a","name":"Hzg Aktor Laden AN","server":"f1b76942.37d308","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.fbh_switch_2","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":900,"y":460,"wires":[[]]},{"id":"f1b76942.37d308","type":"server","z":"","name":"Home Assistant","addon":true}]

Hello,
I have implemented my heating control with "node-red-contrib-ramp-thermostat". Take a look at this.

Holger

I got it to work :slight_smile:
Thanks

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.