Hi everyone,
I hope you’re doing well. I’m currently working on a project involving Node-RED, HomeAssistant, and an S7 PLC, and I’m facing a challenge that I could use some assistance with.
Here’s the situation:
I’ve set up a switch using the switch node in Node-RED, utilizing HomeAssistant entities. This switch controls an S7 output via the contrib S7 node. Simultaneously, I have an S7 input reflecting the status of the S7 with true or false. The switch operates a light, which is also independently controlled outside of HomeAssistant.
Now, my goal is to synchronize the switch’s status with the S7 input, so if the light is turned on, for instance, via a touch panel, HomeAssistant should reflect the change in status.
I’ve attempted to link the S7 input to a call service node using “update entity,” but unfortunately, it doesn’t seem to be functioning as expected.
Has anyone encountered a similar scenario or have suggestions on how I could achieve this integration successfully? Your insights and guidance would be greatly appreciated.
Thank you in advance for your help!
Here is my Flow:
[{"id":"3c8bc872742e839d","type":"ha-switch","z":"9ebc301195a1b88f","name":"test","version":0,"debugenabled":false,"inputs":1,"outputs":2,"entityConfig":"01f09b557f59bd97","enableInput":true,"outputOnStateChange":true,"outputProperties":[{"property":"outputType","propertyType":"msg","value":"state change","valueType":"str"},{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"}],"x":430,"y":160,"wires":[["e1b43ee7518badc6"],["e1b43ee7518badc6"]]},{"id":"e1b43ee7518badc6","type":"s7 out","z":"9ebc301195a1b88f","endpoint":"4d44a1d23acba674","variable":"Licht","name":"S7 Out (Lichtsteuerung)","x":710,"y":160,"wires":[]},{"id":"cc10b402c1b46390","type":"debug","z":"9ebc301195a1b88f","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":440,"y":560,"wires":[]},{"id":"a14618e695ca9658","type":"s7 in","z":"9ebc301195a1b88f","endpoint":"4d44a1d23acba674","mode":"single","variable":"Licht","diff":true,"name":"","x":150,"y":620,"wires":[["cc10b402c1b46390","f4980283f5985386","3c8bc872742e839d"]]},{"id":"a15ad4c4fe3965bb","type":"debug","z":"9ebc301195a1b88f","name":"debug 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":440,"y":380,"wires":[]},{"id":"f4980283f5985386","type":"api-call-service","z":"9ebc301195a1b88f","name":"","server":"5846ae4d.395fd","version":5,"debugenabled":false,"domain":"homeassistant","service":"update_entity","areaId":[],"deviceId":[],"entityId":["switch.nodered_01f09b557f59bd97"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":720,"y":700,"wires":[["a15ad4c4fe3965bb"]]},{"id":"01f09b557f59bd97","type":"ha-entity-config","server":"5846ae4d.395fd","deviceConfig":"","name":"Test","version":"6","entityType":"switch","haConfig":[{"property":"name","value":""},{"property":"icon","value":""},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":""}],"resend":false,"debugEnabled":false},{"id":"4d44a1d23acba674","type":"s7 endpoint","transport":"iso-on-tcp","address":"192.168.1.150","port":"102","rack":"0","slot":"2","localtsaphi":"01","localtsaplo":"00","remotetsaphi":"01","remotetsaplo":"00","connmode":"rack-slot","adapter":"","busaddr":"2","cycletime":"1000","timeout":"5000","name":"","vartable":[{"addr":"DB1,X0.0","name":"Licht"},{"addr":"DB6,X0.0","name":"Licht An"},{"addr":"DB6,X0.1","name":"Licht aus"},{"addr":"DB6,X0.2","name":"Status"}]},{"id":"5846ae4d.395fd","type":"server","name":"Home Assistant","addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"","connectionDelay":false,"cacheJson":false,"heartbeat":false,"heartbeatInterval":"","statusSeparator":"","enableGlobalContextStore":false}]