Newbie help: value comparison

Hello,

already searched but not found really ananswer. So sorry if already answered…

I want to give my blinds some “intelligence”. So beside other checks, i want to open the blinds if it is too windy.
I created one input_number to be able to adjust the value in the UI and one input_boolean which is then used to open the blinds.

Therefore, i created this flow in node-red:

[{"id":"653f7ad5.d55704","type":"api-call-service","z":"6360aac1.79e2e4","name":"Windy = on","server":"c3da42bc.16976","version":1,"debugenabled":false,"service_domain":"input_boolean","service":"turn_on","entityId":"input_boolean.weather_windy","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1070,"y":580,"wires":[[]]},{"id":"4b20e8d4.ca2108","type":"api-call-service","z":"6360aac1.79e2e4","name":"Windy = off","server":"c3da42bc.16976","version":1,"debugenabled":false,"service_domain":"input_boolean","service":"turn_off","entityId":"input_boolean.weather_windy","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1070,"y":640,"wires":[[]]},{"id":"79fe9c7a.167924","type":"api-current-state","z":"6360aac1.79e2e4","name":"Höher als Schwellwert?","server":"c3da42bc.16976","version":1,"outputs":2,"halt_if":"payload","halt_if_type":"msg","halt_if_compare":"lte","override_topic":false,"entity_id":"input_number.weather_high_windy_value","state_type":"num","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":470,"y":620,"wires":[["653f7ad5.d55704"],["4b20e8d4.ca2108"]]},{"id":"af35e127.f0c11","type":"server-state-changed","z":"6360aac1.79e2e4","name":"Aktueller Wert","server":"c3da42bc.16976","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.wupws_windspeed","entityidfiltertype":"exact","outputinitially":true,"state_type":"num","haltifstate":"","halt_if_type":"num","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":130,"y":620,"wires":[["79fe9c7a.167924"]]},{"id":"c3da42bc.16976","type":"server","z":"","name":"Home Assistant"}]

My problem is having the comparison of the values because the middle is always true…
Sure i am doing a newbie fault…?

Thanks for your help in advance!
/ Ralf

if the wind speed threshold is not something you always plan to change , hard code it in the trigger:state node. if the wind speed is =>7, it will send the message to upper output.

Hi,

I was just playing around with Nodered, do you mean something like that?

[{"id":"5ef33b3f.8c1924","type":"api-call-service","z":"7bebfb4.6092904","name":"Windy = on","server":"97761cf1.9c64b","version":1,"debugenabled":true,"service_domain":"input_boolean","service":"turn_on","entityId":"input_boolean.wind_on","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":710,"y":140,"wires":[[]]},{"id":"43d82cd.202a1d4","type":"api-call-service","z":"7bebfb4.6092904","name":"Windy = off","server":"97761cf1.9c64b","version":1,"debugenabled":true,"service_domain":"input_boolean","service":"turn_off","entityId":"input_boolean.wind_on","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":710,"y":200,"wires":[[]]},{"id":"e3eb7975.06db58","type":"server-state-changed","z":"7bebfb4.6092904","name":"Aktueller Wert","server":"97761cf1.9c64b","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_number.wind1","entityidfiltertype":"exact","outputinitially":true,"state_type":"num","haltifstate":"","halt_if_type":"num","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":110,"y":140,"wires":[["9c2c7fef.68f06"]]},{"id":"ad759aa4.64c6b8","type":"server-state-changed","z":"7bebfb4.6092904","name":"Aktueller Wert","server":"97761cf1.9c64b","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_number.wind2_schwelle","entityidfiltertype":"exact","outputinitially":true,"state_type":"num","haltifstate":"","halt_if_type":"num","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":110,"y":200,"wires":[["1b961d71.58dc13"]]},{"id":"9c2c7fef.68f06","type":"function","z":"7bebfb4.6092904","name":"Var Wind Sensor","func":"global.set('wind_sensor', msg.payload);\nreturn msg;","outputs":1,"noerr":0,"x":310,"y":140,"wires":[["1a55aa2a.753326"]]},{"id":"1b961d71.58dc13","type":"function","z":"7bebfb4.6092904","name":"Var Wind Schwellwert","func":"global.set('wind_schwelle', msg.payload);\nreturn msg;","outputs":1,"noerr":0,"x":320,"y":200,"wires":[["1a55aa2a.753326"]]},{"id":"1a55aa2a.753326","type":"function","z":"7bebfb4.6092904","name":"Var Vergleich","func":"if (global.get('wind_sensor') > global.get('wind_schwelle')) {\n    msg.payload = \"blabla\";\n    return [msg, null]\n}else{\n    return [null, msg]\n}\nreturn msg;\n","outputs":2,"noerr":0,"x":530,"y":160,"wires":[["5ef33b3f.8c1924"],["43d82cd.202a1d4"]]},{"id":"97761cf1.9c64b","type":"server","z":"","name":"Home Assistant"}]

I took 2 input_numbers because of testing.
Greetings pwgdrx

@pwgdrx,

exactly this is what i want to achieve!
I am thinking correct the first two functions after getting the value are to have these globally available?

Flow is working, many thanks for your great help!
/ Ralf

EDIT: @serkank: Surely it would be easier to hard-code it, do not change it too often but would prefer to have an input_number. Nevertheless, thanks for your reply, too!

Hi,

global was random, I had just tested that.
Flow or context, depending on what you need.
With pleasure
pwgdrx

I always try to NOT hardcode constants/configuration values. You can do it using function but it’s easier/better to use NodeRed nodes as long as it’s possible.
I’m doing it this way:

Timestamp is configured to be delayed by 0.1s after start:

Then initial values, as many as you want: