Node-RED - schedule cover position

Hello. I have setup a Node-RED automation to schedule closing and opening my window covers. I created some helpers to be able to enter a time for closing and opening them in my Lovelace Dashboard. Also I created some switches (input_bolean helpers) to activate and deactivate closing / opening automatically. For the scheduling part I used the schedex node. This works pretty fine so far.

Now I want to be able to set the position instead of closing or opening them entirely. So I created another helper to adjust the position via a slider in LL. Works fine, too. But what I’m struggling with is how I can schedule to emit the position as schedex only emits off an on.

Any ideas?

[{"id":"78e478b4055c0c1d","type":"tab","label":"Flow 4","disabled":false,"info":""},{"id":"7aa8944030de87d4","type":"api-call-service","z":"78e478b4055c0c1d","name":"Wohnzimmer Rollo Position","server":"86616542.19f378","version":3,"debugenabled":false,"service_domain":"cover","service":"set_cover_position","entityId":"cover.rollo_wohnzimmer","data":"{\"position\":\"{{payload}}\"}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1840,"y":260,"wires":[[]]},{"id":"048f1c350c15c1d0","type":"trigger-state","z":"78e478b4055c0c1d","name":"Zeitgeber Schließen Wohnzimmer Rollo","server":"86616542.19f378","version":0,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"input_datetime.zeitgeber_schliessen_wohnzimmer_rollo","entityidfiltertype":"exact","debugenabled":false,"constraints":[],"outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":220,"y":240,"wires":[["8f81e312043092d7"],[]]},{"id":"c554c8729568f1b1","type":"trigger-state","z":"78e478b4055c0c1d","name":"Zeitgeber Öffnen Wohnzimmer Rollo","server":"86616542.19f378","version":0,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"input_datetime.zeitgeber_offnen_wohnzimmer_rollo","entityidfiltertype":"exact","debugenabled":false,"constraints":[],"outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":210,"y":320,"wires":[["ec3268429b4e7826"],[]]},{"id":"8f81e312043092d7","type":"ha-wait-until","z":"78e478b4055c0c1d","name":"","server":"86616542.19f378","version":0,"outputs":1,"entityId":"input_boolean.automatisierung_wohnzimmer_rollo_schliessen","entityIdFilterType":"exact","property":"state","comparator":"is","value":"on","valueType":"str","timeout":0,"timeoutType":"num","timeoutUnits":"seconds","entityLocation":"","entityLocationType":"none","checkCurrentState":true,"blockInputOverrides":true,"x":500,"y":240,"wires":[["e95e9509a31b98bc"]]},{"id":"ec3268429b4e7826","type":"ha-wait-until","z":"78e478b4055c0c1d","name":"","server":"86616542.19f378","version":0,"outputs":1,"entityId":"input_boolean.automatisierung_wohnzimmer_rollo_offnen","entityIdFilterType":"exact","property":"state","comparator":"is","value":"on","valueType":"str","timeout":0,"timeoutType":"num","timeoutUnits":"seconds","entityLocation":"","entityLocationType":"none","checkCurrentState":true,"blockInputOverrides":true,"x":500,"y":320,"wires":[["16f5bdba8aa3a479"]]},{"id":"e95e9509a31b98bc","type":"moment","z":"78e478b4055c0c1d","name":"","topic":"","input":"","inputType":"msg","inTz":"Europe/Berlin","adjAmount":0,"adjType":"days","adjDir":"add","format":"LT","locale":"de_DE","output":"","outputType":"msg","outTz":"Europe/Berlin","x":740,"y":260,"wires":[["109bfc395978f891"]]},{"id":"16f5bdba8aa3a479","type":"moment","z":"78e478b4055c0c1d","name":"","topic":"","input":"","inputType":"msg","inTz":"Europe/Berlin","adjAmount":0,"adjType":"days","adjDir":"add","format":"LT","locale":"de_DE","output":"","outputType":"msg","outTz":"Europe/Berlin","x":740,"y":300,"wires":[["e60c24e1047a0541"]]},{"id":"109bfc395978f891","type":"ha-entity","z":"78e478b4055c0c1d","name":"Uhrzeit Schließen Wohnzimmer Rollo","server":"86616542.19f378","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Uhrzeit Schließen Wohnzimmer Rollo"},{"property":"device_class","value":"sensor"},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1030,"y":140,"wires":[["61dd90638f7eb8b0"]]},{"id":"e60c24e1047a0541","type":"ha-entity","z":"78e478b4055c0c1d","name":"Uhrzeit Öffnen Wohnzimmer Rollo","server":"86616542.19f378","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Uhrzeit Öffnen Wohnzimmer Rollo"},{"property":"device_class","value":"sensor"},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1020,"y":400,"wires":[["d68138f30b29cbfd"]]},{"id":"d4e85b864059b77c","type":"server-state-changed","z":"78e478b4055c0c1d","name":"Schalter an/aus","server":"86616542.19f378","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_boolean.automatisierung_wohnzimmer_rollo_schliessen","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":960,"y":60,"wires":[["08f837b5f8b44642"],["e6f129953a8791f7"]]},{"id":"08f837b5f8b44642","type":"template","z":"78e478b4055c0c1d","name":"Activate Automation ","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"suspended false","output":"str","x":1200,"y":40,"wires":[["981d0d74693eaacb"]]},{"id":"e6f129953a8791f7","type":"template","z":"78e478b4055c0c1d","name":"Suspend Automation ","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"suspended true","output":"str","x":1200,"y":80,"wires":[["981d0d74693eaacb"]]},{"id":"61dd90638f7eb8b0","type":"template","z":"78e478b4055c0c1d","name":"Offtime","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"offtime {{{payload}}}","output":"str","x":1280,"y":160,"wires":[["981d0d74693eaacb","ad6dfd7e46750596"]]},{"id":"d68138f30b29cbfd","type":"template","z":"78e478b4055c0c1d","name":"Ontime","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"ontime {{{payload}}}","output":"str","x":1280,"y":380,"wires":[["f811026bb1b3cc36","3d68b7fe83970bd2"]]},{"id":"976c79ee95af33c4","type":"server-state-changed","z":"78e478b4055c0c1d","name":"Schalter an/aus","server":"86616542.19f378","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_boolean.automatisierung_wohnzimmer_rollo_offnen","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":960,"y":480,"wires":[["719bf36cfe35786c"],["d321d769c8b68f99"]]},{"id":"719bf36cfe35786c","type":"template","z":"78e478b4055c0c1d","name":"Activate Automation ","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"suspended false","output":"str","x":1200,"y":460,"wires":[["f811026bb1b3cc36"]]},{"id":"d321d769c8b68f99","type":"template","z":"78e478b4055c0c1d","name":"Suspend Automation ","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"suspended true","output":"str","x":1200,"y":500,"wires":[["f811026bb1b3cc36"]]},{"id":"3d68b7fe83970bd2","type":"debug","z":"78e478b4055c0c1d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1410,"y":460,"wires":[]},{"id":"f811026bb1b3cc36","type":"schedex","z":"78e478b4055c0c1d","name":"Schedex","passthroughunhandled":false,"suspended":false,"lat":"","lon":"","ontime":"","ontopic":"","onpayload":"","onoffset":0,"onrandomoffset":0,"offtime":"","offtopic":"","offpayload":"","offoffset":0,"offrandomoffset":0,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"sun":true,"x":1480,"y":400,"wires":[["7aa8944030de87d4","24c46dd306452d9c"]]},{"id":"981d0d74693eaacb","type":"schedex","z":"78e478b4055c0c1d","name":"Schedex","passthroughunhandled":true,"suspended":false,"lat":"","lon":"","ontime":"","ontopic":"","onpayload":"","onoffset":0,"onrandomoffset":0,"offtime":"","offtopic":"","offpayload":"","offoffset":0,"offrandomoffset":0,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"sun":true,"x":1480,"y":120,"wires":[["37b86c74c3f3ccb4","7aa8944030de87d4"]]},{"id":"37b86c74c3f3ccb4","type":"debug","z":"78e478b4055c0c1d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1670,"y":40,"wires":[]},{"id":"ad6dfd7e46750596","type":"debug","z":"78e478b4055c0c1d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1430,"y":60,"wires":[]},{"id":"24c46dd306452d9c","type":"debug","z":"78e478b4055c0c1d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1690,"y":480,"wires":[]},{"id":"2ac3a7c295203020","type":"server-state-changed","z":"78e478b4055c0c1d","name":"Cover Level","server":"86616542.19f378","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_number.offnung_wohnzimmer_rollo","entityidfiltertype":"exact","outputinitially":false,"state_type":"num","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"}],"x":1320,"y":260,"wires":[["7aa8944030de87d4"]]},{"id":"86616542.19f378","type":"server","name":"Home Assistant","version":1,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

Hi,

I don’t know how Schedex is working, but isn’t the following possible?

Whenever you want to “close” the cover in your flow, instead of calling service cover.close_cover do this:

  • Read the value from your helper with the cover position for “closed” with current_state node
  • Use the value for your call-service node with service cover.set_position and data like {"position":"{{payload}}"}

Similar for opening.

This would do it if the scheduling thing wasn’t in the way. If the helper for the cover emits a number and calls service cover.set_position {“position”:"{{payload}}"} isn’t even needed. It sets the cover position anytime the number is emitted by the helper. But I want this to be scheduled to the time given from my input.datetime helper. And so far schedex does only emit “on” or “off” at a certain time. It doesn’t seem to be able to do something else. I’m not bound to Schedex, if there’s any other node that does the trick, I’ll be fine with it.

Using two time nodes, one for opening the other for closing. On the closing one use the payload field to override the default call-service node config with the set_cover_position service and position. Exposing each time node will create two switches in HA that will allow you to disable each node individually.

image

[{"id":"4a93af81fdd121a9","type":"ha-time","z":"78e478b4055c0c1d","name":"Zeitgeber Schließen Wohnzimmer Rollo","server":"","version":0,"exposeToHomeAssistant":true,"haConfig":[{"property":"name","value":"Close Binds"},{"property":"icon","value":""}],"entityId":"input_datetime.zeitgeber_schliessen_wohnzimmer_rollo","property":"state","offset":0,"offsetType":"num","offsetUnits":"minutes","randomOffset":false,"repeatDaily":true,"payload":"$entity().state","payloadType":"jsonata","debugenabled":false,"x":260,"y":576,"wires":[["1e1035ab41a12d57"]]},{"id":"80c801fbff73d3af","type":"ha-time","z":"78e478b4055c0c1d","name":"Zeitgeber Öffnen Wohnzimmer Rollo","server":"","version":0,"exposeToHomeAssistant":true,"haConfig":[{"property":"name","value":"Open Blinds"},{"property":"icon","value":""}],"entityId":"input_datetime.zeitgeber_offnen_wohnzimmer_rollo","property":"state","offset":0,"offsetType":"num","offsetUnits":"minutes","randomOffset":false,"repeatDaily":true,"payload":"{\"service\": \"set_cover_position\", \"data\": {\"position\": $entities(\"input_number.offnung_wohnzimmer_rollo\").state}}","payloadType":"jsonata","debugenabled":false,"x":252,"y":624,"wires":[["1e1035ab41a12d57"]]},{"id":"1e1035ab41a12d57","type":"api-call-service","z":"78e478b4055c0c1d","name":"Wohnzimmer Rollo Position","server":"","version":3,"debugenabled":false,"service_domain":"cover","service":"close_cover","entityId":"cover.rollo_wohnzimmer","data":"","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":584,"y":576,"wires":[[]]}]

That seems to work. Thank you! But I cannot figure where to find the switches exposed by the time nodes.

If you looking under Configuration > Integrations > Node-RED Companion in HA. You should be able to find their entity ids there.

Got them. But I’m afraid the {"service": "set_cover_position", "data": {"position": $entities("input_number.offnung_wohnzimmer_rollo").state}} part is not working. “Call-service” complains that it would rather have an integer.

Just for your information:
Do you know these nodes?

I really like the blind-control node.

wrap $entities("input_number.offnung_wohnzimmer_rollo").state with $number()

$number($entities("input_number.offnung_wohnzimmer_rollo").state)

Dude! It works! Thanks for your help.