Cover via NodeRed

Hello, my name is Mark and I have only been using ha for a few days.
My blinds are controlled via an S7 PLC. Now I have set up a connection to the PLC via NodeRed and get a position value in integer between 0 and 100 for each blind. This value provides the current position and if it changes, the blind can also be controlled via it.
I get the value as a number in a dasboard and can also control it this way.
But I would like to configure the blind as a real cover.
The question now is, how can I display this value as a cover and also control it?
How should I configure Cover to control the blinds via NodeRed, e.g. with CallService?
I hope you can help me. Many thanks in advance.

You can use the HA sensor node in NR to create a sensor inside HA. Which then can be used in a Cover template.

Another option is to use a mqtt cover.

Hello Kermit,
I have used the #number node in nodered and can also move the blinds with it.
Which Device_Class do I have to use for sensor_node?
How should the cover_template be configured with this sensor?
Can you please give me an example?
Thank you very much.

Hi ESPler, my house is also controlled via S7 and I would control the blinds as you via the cover template in HA. I’ve added the cover in configuration.yaml but I have no idea how do get the up / stop / down event from HA into NodeRed. Did you find a solution? Thanks Alois

[{"id":"e3d4a01dbcb85d2d","type":"inject","z":"120358abd7c22d30","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":1602,"y":448,"wires":[["651c441f923ade8f"]]},{"id":"8a92c54133bcb889","type":"comment","z":"120358abd7c22d30","name":"data from s7","info":"","x":1620,"y":400,"wires":[]},{"id":"a3e43f16ee56a4d5","type":"inject","z":"120358abd7c22d30","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"100","payloadType":"num","x":1598,"y":496,"wires":[["651c441f923ade8f"]]},{"id":"23e3ac5ed8283ea7","type":"inject","z":"120358abd7c22d30","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"55","payloadType":"num","x":1598,"y":544,"wires":[["651c441f923ade8f"]]},{"id":"651c441f923ade8f","type":"ha-sensor","z":"120358abd7c22d30","name":"","entityConfig":"756780d81b3683b9","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":1778,"y":448,"wires":[[]]},{"id":"3e2c94c727ddd8e1","type":"ha-button","z":"120358abd7c22d30","name":"s7 up","version":0,"debugenabled":false,"outputs":1,"entityConfig":"6d3e3543ce4394f7","outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"x":1914,"y":448,"wires":[["4292ccd359021bdf"]]},{"id":"325c6f399ee046d1","type":"ha-button","z":"120358abd7c22d30","name":"s7 down","version":0,"debugenabled":false,"outputs":1,"entityConfig":"528d080eee9a4cfc","outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"x":1920,"y":496,"wires":[["6ad1925d63be92b3"]]},{"id":"7faadffae71705b6","type":"ha-button","z":"120358abd7c22d30","name":"s7 stop","version":0,"debugenabled":false,"outputs":1,"entityConfig":"8932432c48a5e728","outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"x":1910,"y":544,"wires":[["c56a2bb119bf8910"]]},{"id":"4292ccd359021bdf","type":"debug","z":"120358abd7c22d30","name":"send up to s7","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":2112,"y":448,"wires":[]},{"id":"6ad1925d63be92b3","type":"debug","z":"120358abd7c22d30","name":"send down to s7","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":2112,"y":496,"wires":[]},{"id":"c56a2bb119bf8910","type":"debug","z":"120358abd7c22d30","name":"send stop to s7","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":2112,"y":544,"wires":[]},{"id":"756780d81b3683b9","type":"ha-entity-config","server":"2dad33ee.42bf5c","deviceConfig":"","name":"s7 position","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"s7 position"},{"property":"icon","value":""},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""}],"resend":false,"debugEnabled":false},{"id":"6d3e3543ce4394f7","type":"ha-entity-config","server":"2dad33ee.42bf5c","deviceConfig":"","name":"s7 up","version":"6","entityType":"button","haConfig":[{"property":"name","value":"s7 up"},{"property":"icon","value":""},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":""}],"resend":false,"debugEnabled":false},{"id":"528d080eee9a4cfc","type":"ha-entity-config","server":"2dad33ee.42bf5c","deviceConfig":"","name":"s7 down","version":"6","entityType":"button","haConfig":[{"property":"name","value":"s7 down"},{"property":"icon","value":""},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":""}],"resend":false,"debugEnabled":false},{"id":"8932432c48a5e728","type":"ha-entity-config","server":"2dad33ee.42bf5c","deviceConfig":"","name":"s7 stop","version":"6","entityType":"button","haConfig":[{"property":"name","value":"s7 stop"},{"property":"icon","value":""},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":""}],"resend":false,"debugEnabled":false}]
cover:
  - platform: template
    covers:
      s7:
        friendly_name: s7 blind
        position_template: "{{ states('sensor.s7_position') }}"
        open_cover:
          service: button.press
          data:
            entity_id: button.s7_up
        close_cover:
          service: button.press
          data:
            entity_id: button.s7_down
        stop_cover:
          service: button.press
          data:
            entity_id: button.s7_stop
1 Like

Here’s a change to add position to be set

[{"id":"e3d4a01dbcb85d2d","type":"inject","z":"120358abd7c22d30","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":1602,"y":448,"wires":[["651c441f923ade8f"]]},{"id":"8a92c54133bcb889","type":"comment","z":"120358abd7c22d30","name":"data from s7","info":"","x":1620,"y":400,"wires":[]},{"id":"a3e43f16ee56a4d5","type":"inject","z":"120358abd7c22d30","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"100","payloadType":"num","x":1598,"y":496,"wires":[["651c441f923ade8f"]]},{"id":"23e3ac5ed8283ea7","type":"inject","z":"120358abd7c22d30","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"55","payloadType":"num","x":1598,"y":544,"wires":[["651c441f923ade8f"]]},{"id":"651c441f923ade8f","type":"ha-sensor","z":"120358abd7c22d30","name":"","entityConfig":"756780d81b3683b9","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":1778,"y":448,"wires":[[]]},{"id":"3e2c94c727ddd8e1","type":"ha-button","z":"120358abd7c22d30","name":"s7 up","version":0,"debugenabled":false,"outputs":1,"entityConfig":"6d3e3543ce4394f7","outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"x":1914,"y":448,"wires":[["4292ccd359021bdf"]]},{"id":"325c6f399ee046d1","type":"ha-button","z":"120358abd7c22d30","name":"s7 down","version":0,"debugenabled":false,"outputs":1,"entityConfig":"528d080eee9a4cfc","outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"x":1920,"y":496,"wires":[["6ad1925d63be92b3"]]},{"id":"7faadffae71705b6","type":"ha-button","z":"120358abd7c22d30","name":"s7 stop","version":0,"debugenabled":false,"outputs":1,"entityConfig":"8932432c48a5e728","outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"x":1910,"y":544,"wires":[["c56a2bb119bf8910"]]},{"id":"4292ccd359021bdf","type":"debug","z":"120358abd7c22d30","name":"send up to s7","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":2112,"y":448,"wires":[]},{"id":"6ad1925d63be92b3","type":"debug","z":"120358abd7c22d30","name":"send down to s7","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":2112,"y":496,"wires":[]},{"id":"c56a2bb119bf8910","type":"debug","z":"120358abd7c22d30","name":"send stop to s7","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":2112,"y":544,"wires":[]},{"id":"ee640d37f3f1edb5","type":"ha-number","z":"120358abd7c22d30","name":"s7 position","version":1,"debugenabled":false,"inputs":0,"outputs":1,"entityConfig":"623e0ce17fa8d6a8","mode":"listen","value":"payload","valueType":"msg","outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"value"},{"property":"previousValue","propertyType":"msg","value":"","valueType":"previousValue"}],"x":1924,"y":592,"wires":[["1ccc8b62640392fd"]]},{"id":"1ccc8b62640392fd","type":"debug","z":"120358abd7c22d30","name":"send position to s7","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":2122,"y":592,"wires":[]},{"id":"756780d81b3683b9","type":"ha-entity-config","server":"2dad33ee.42bf5c","deviceConfig":"","name":"s7 position","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"s7 position"},{"property":"icon","value":""},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""}],"resend":false,"debugEnabled":false},{"id":"6d3e3543ce4394f7","type":"ha-entity-config","server":"2dad33ee.42bf5c","deviceConfig":"","name":"s7 up","version":"6","entityType":"button","haConfig":[{"property":"name","value":"s7 up"},{"property":"icon","value":""},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":""}],"resend":false,"debugEnabled":false},{"id":"528d080eee9a4cfc","type":"ha-entity-config","server":"2dad33ee.42bf5c","deviceConfig":"","name":"s7 down","version":"6","entityType":"button","haConfig":[{"property":"name","value":"s7 down"},{"property":"icon","value":""},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":""}],"resend":false,"debugEnabled":false},{"id":"8932432c48a5e728","type":"ha-entity-config","server":"2dad33ee.42bf5c","deviceConfig":"","name":"s7 stop","version":"6","entityType":"button","haConfig":[{"property":"name","value":"s7 stop"},{"property":"icon","value":""},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":""}],"resend":false,"debugEnabled":false},{"id":"623e0ce17fa8d6a8","type":"ha-entity-config","server":"2dad33ee.42bf5c","deviceConfig":"","name":"s7 position","version":"6","entityType":"number","haConfig":[{"property":"name","value":"s7 position"},{"property":"icon","value":""},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":""},{"property":"min_value","value":""},{"property":"max_value","value":""},{"property":"step_value","value":""},{"property":"mode","value":"auto"}],"resend":false,"debugEnabled":false}]
cover:
  - platform: template
    covers:
      s7:
        friendly_name: s7 blind
        position_template: "{{ states('sensor.s7_position') }}"
        open_cover:
          service: button.press
          data:
            entity_id: button.s7_up
        close_cover:
          service: button.press
          data:
            entity_id: button.s7_down
        stop_cover:
          service: button.press
          data:
            entity_id: button.s7_stop
        set_cover_position:
          service: number.set_value
          data:
            entity_id: number.s7_position
            value: "{{ position }}"

edit:
open_cover and close_cover are optional. If you leave them out the open and close functions in the UI will send 0 and 100 respectively to the number node.

1 Like

Hey Kermit,
That’s exactly what I was looking for. Unfortunately, I won’t be home to test it for another two days.
Many thanks for your great help.
greetings, mark

@Luis Unfortunately I won’t be home for another two days to try something out.
but I’ll be happy to keep you up to date…

@kermit: thank you very much. It works. :grinning:
@ESPler: I added it 1:1 in node red and configuration.yaml and it works. I only have to change something for the position. I only have the running times for each blind, but I already have an idea how to solve this. Great and many thanks for your help.
Luis

@Kermit: I would need your help again please.
I hvae two funktion for one button.

  • long press of the button open the blind and
  • a short press will only tilt it.

Therefore another button would be useful for this function. :grinning:
I found a post exaktly for this

At which point should I insert this in the cover template?
Many thanks, Luis

Use another sensor node and number node for the tilt position. Add a set_cover_tilt_position to the yaml that calls the number.set_value for the new number entity.

1 Like

I have now been able to test everything and it works perfectly.
I have removed open_cover / close_cover / stop_cover as my blinds only move over the value.
Since I had a few other problems, here are a few more comments:
I had to rotate position 0 and 100 because my blinds are open at 0 and closed at 100. function_node msg.payload = 100 - msg.payload; return msg;.
If someone like me uses an S7 PLC, the check mark for “Send only on value change” should be removed from the S7_In node for the sensor. Otherwise the status is not updated when HA is restarted, the blinds cannot be controlled and Satus is displayed as unknown.
If you want to control the position of the blind from nodered, you can do this with node Call_Service - Set Cover Position.
If you want to control the position from the payload, enter
{“position”:“{{payload}}”} as JSON.
Using a trigger, e.g. time, the blinds can be moved to a specific position with JSON
{“position”:20}
Thanks again for your help and best regards from Germany.