I would like something built into HA for tcp serial. I wanted to share my workaround for a situation I have.
- I have a Anthem MRX500 receiver that has rs232 only for control/monitoriong.
- I have a IP-to-rs232 device (global cache iTach) connected to the receiver.
- Node Red to communicate with a IP-to-rs232 device.
- Send events that NR monitors and acts on.
- NR monitors the tcp connection and parses the responses.
- Returned data is sent as events to HA.
- Automations/sensors etc in HA use the event data.
It still needs some polishing but the concept works for me and might for some of your situations.
Here is the NR flow for those who want it.
[{"id":"c9e6e970e7729a45","type":"tab","label":"mrx","disabled":false,"info":""},{"id":"8132adaa70942957","type":"tcp request","z":"c9e6e970e7729a45","server":"192.168.20.134","port":"4999","out":"char","splitc":"0xa","name":"","x":390,"y":540,"wires":[["14b2d28e8de2f5d2"]]},{"id":"14b2d28e8de2f5d2","type":"function","z":"c9e6e970e7729a45","name":"","func":"msg.payload = msg.payload.toString('utf8');\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":620,"y":540,"wires":[["5792ecefde09dc38","514d70cdd8bb0d38"]]},{"id":"ffc4835302c239bf","type":"server-events","z":"c9e6e970e7729a45","name":"","server":"f41510c7.a2386","version":1,"event_type":"anthem_mrx","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"waitForRunning":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"$outputData(\"eventData\").event_type","valueType":"jsonata"}],"x":110,"y":320,"wires":[["ecc5ab4c30f7ad1e","1ad8f3cc011dc350"]]},{"id":"6b4049cbc503658b","type":"function","z":"c9e6e970e7729a45","name":"add \\x0a","func":"msg.payload = msg.payload + \"\\x0a\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":800,"y":320,"wires":[["18543f9ffde65ec6","e100c19bbae4a84c"]]},{"id":"18543f9ffde65ec6","type":"debug","z":"c9e6e970e7729a45","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":970,"y":260,"wires":[]},{"id":"ecc5ab4c30f7ad1e","type":"debug","z":"c9e6e970e7729a45","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":310,"y":380,"wires":[]},{"id":"b29887a1a73587b1","type":"ha-fire-event","z":"c9e6e970e7729a45","name":"","server":"f41510c7.a2386","version":0,"event":"anthem_mrx","data":"","dataType":"json","x":750,"y":800,"wires":[["8b5e354855a89558"]]},{"id":"1ad8f3cc011dc350","type":"switch","z":"c9e6e970e7729a45","name":"only send events","property":"payload.event.send","propertyType":"msg","rules":[{"t":"nempty"}],"checkall":"true","repair":false,"outputs":1,"x":350,"y":320,"wires":[["0d73c4de97520ccd"]]},{"id":"5792ecefde09dc38","type":"debug","z":"c9e6e970e7729a45","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":790,"y":480,"wires":[]},{"id":"fd84c80ae0667a44","type":"inject","z":"c9e6e970e7729a45","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"P1?","payloadType":"str","x":110,"y":140,"wires":[["b17c136b939ab089"]]},{"id":"4a076656ef5765d0","type":"inject","z":"c9e6e970e7729a45","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"P1V-59","payloadType":"str","x":110,"y":180,"wires":[["b17c136b939ab089"]]},{"id":"24e22ee739fe9475","type":"inject","z":"c9e6e970e7729a45","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"P1P0","payloadType":"str","x":110,"y":100,"wires":[["b17c136b939ab089"]]},{"id":"ee91995f75cab87c","type":"inject","z":"c9e6e970e7729a45","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"P1P1","payloadType":"str","x":250,"y":100,"wires":[["b17c136b939ab089"]]},{"id":"0d73c4de97520ccd","type":"change","z":"c9e6e970e7729a45","name":"move event send","rules":[{"t":"move","p":"msg.payload.event.send","pt":"msg","to":"msg.payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":590,"y":320,"wires":[["6b4049cbc503658b","47315587052f1d6d"]]},{"id":"d5bb86918d28d34f","type":"switch","z":"c9e6e970e7729a45","name":"query","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"?","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":190,"y":1060,"wires":[[],["076483599ad55868"]],"outputLabels":["yes","no"]},{"id":"96716abf63261ca6","type":"change","z":"c9e6e970e7729a45","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"P1?","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":1060,"wires":[["1352090141652f40","1fe114fc39c75a2a"]]},{"id":"076483599ad55868","type":"delay","z":"c9e6e970e7729a45","name":"","pauseType":"delay","timeout":"500","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"x":370,"y":1060,"wires":[["96716abf63261ca6"]]},{"id":"b17c136b939ab089","type":"link out","z":"c9e6e970e7729a45","name":"","links":["ecc3427a301c15ad"],"x":395,"y":100,"wires":[]},{"id":"d338be1d8a537133","type":"link in","z":"c9e6e970e7729a45","name":"","links":["1352090141652f40"],"x":615,"y":260,"wires":[["6b4049cbc503658b"]]},{"id":"e2cb8a287389d028","type":"link in","z":"c9e6e970e7729a45","name":"","links":["47315587052f1d6d"],"x":75,"y":1060,"wires":[["d5bb86918d28d34f"]]},{"id":"e100c19bbae4a84c","type":"link out","z":"c9e6e970e7729a45","name":"","links":["db4f35fa89e37868"],"x":935,"y":320,"wires":[]},{"id":"1352090141652f40","type":"link out","z":"c9e6e970e7729a45","name":"","links":["d338be1d8a537133"],"x":855,"y":1060,"wires":[]},{"id":"1073b6c8dfbe31f7","type":"comment","z":"c9e6e970e7729a45","name":"If the send message is a command send a follow up query","info":"","x":270,"y":1000,"wires":[]},{"id":"e305fb8a6645e8a2","type":"comment","z":"c9e6e970e7729a45","name":"send the mesage and get the response","info":"","x":190,"y":480,"wires":[]},{"id":"20776412396a6c82","type":"comment","z":"c9e6e970e7729a45","name":"test commands","info":"","x":120,"y":40,"wires":[]},{"id":"4d0487310ad158c0","type":"comment","z":"c9e6e970e7729a45","name":"reeived event and create tcp message","info":"","x":170,"y":280,"wires":[]},{"id":"db4f35fa89e37868","type":"link in","z":"c9e6e970e7729a45","name":"","links":["e100c19bbae4a84c"],"x":55,"y":540,"wires":[["295ae929b968e149"]]},{"id":"47315587052f1d6d","type":"link out","z":"c9e6e970e7729a45","name":"","links":["e2cb8a287389d028"],"x":755,"y":380,"wires":[]},{"id":"1fe114fc39c75a2a","type":"debug","z":"c9e6e970e7729a45","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":850,"y":1120,"wires":[]},{"id":"d1f939d0a1ea6e1f","type":"comment","z":"c9e6e970e7729a45","name":"parse the repsponse","info":"","x":130,"y":700,"wires":[]},{"id":"bf9d9e038d9be7cb","type":"link in","z":"c9e6e970e7729a45","name":"","links":["18068d9d9e112f6b"],"x":55,"y":800,"wires":[["d9dc94f16fd1410f"]]},{"id":"18068d9d9e112f6b","type":"link out","z":"c9e6e970e7729a45","name":"","links":["bf9d9e038d9be7cb"],"x":1055,"y":540,"wires":[]},{"id":"514d70cdd8bb0d38","type":"switch","z":"c9e6e970e7729a45","name":"response contains zone flag","property":"payload","propertyType":"msg","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":860,"y":540,"wires":[["18068d9d9e112f6b"]]},{"id":"875b1e7e0c7f2186","type":"inject","z":"c9e6e970e7729a45","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"P1V?","payloadType":"str","x":110,"y":220,"wires":[["b17c136b939ab089"]]},{"id":"d9dc94f16fd1410f","type":"switch","z":"c9e6e970e7729a45","name":"","property":"payload","propertyType":"msg","rules":[{"t":"regex","v":"P(.)S(.)V(.*?)M(.)D(.)","vt":"str","case":false},{"t":"regex","v":"P(.)VM(.*)","vt":"str","case":false},{"t":"cont","v":"Main Off","vt":"str"},{"t":"cont","v":"Zone2 Off","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":5,"x":150,"y":800,"wires":[["2f7a889f64e96de6"],["c01d41cab5e1715b"],["0f96929e6e115670"],["e4f47f6b164900ee"],["d9f7cb464650bf40"]],"outputLabels":["Pz?","","","",""]},{"id":"c01d41cab5e1715b","type":"function","z":"c9e6e970e7729a45","name":"PzV?","func":"var regExp = /P(.)VM(.*)/;\nvar results = regExp.exec(msg.payload);\n\n// organise the zone data\nrecv = {};\nrecv.raw = msg.payload;\n\nzone = {};\nzone.power = 1;\nzone.volume = results[3];\n\nrecv[results[1]] = zone;\n\n// creat the payload for the HA event\nmsg.payload = {};\nmsg.payload.data = {};\nmsg.payload.data.recv = recv;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":310,"y":800,"wires":[["b29887a1a73587b1"]]},{"id":"40654b7215955d45","type":"inject","z":"c9e6e970e7729a45","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"P1MT","payloadType":"str","x":250,"y":140,"wires":[["b17c136b939ab089"]]},{"id":"ecc3427a301c15ad","type":"link in","z":"c9e6e970e7729a45","name":"","links":["b17c136b939ab089"],"x":615,"y":220,"wires":[["6b4049cbc503658b","47315587052f1d6d"]]},{"id":"8fb06ee60c7189a2","type":"inject","z":"c9e6e970e7729a45","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"P2?","payloadType":"str","x":250,"y":180,"wires":[["b17c136b939ab089"]]},{"id":"295ae929b968e149","type":"delay","z":"c9e6e970e7729a45","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"4","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"allowrate":false,"x":170,"y":540,"wires":[["8132adaa70942957"]]},{"id":"2f7a889f64e96de6","type":"function","z":"c9e6e970e7729a45","name":"Pz?","func":"var regExp = /P(.)S(.)V(.*?)M(.)D(.)/;\nvar results = regExp.exec(msg.payload);\n\n// organise the zone data\nrecv = {};\nrecv.raw = msg.payload;\n\nzone = {};\nzone.power = 1;\nzone.source = results[2];\nzone.volume = results[3];\nzone.mute = results[4];\nzone.decoder = results[5];\n\nrecv[results[1]] = zone;\n\n// creat the payload for the HA event\nmsg.payload = {};\nmsg.payload.data = {};\nmsg.payload.data.recv = recv;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":310,"y":760,"wires":[["b29887a1a73587b1"]]},{"id":"8b5e354855a89558","type":"debug","z":"c9e6e970e7729a45","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":930,"y":800,"wires":[]},{"id":"d9f7cb464650bf40","type":"function","z":"c9e6e970e7729a45","name":"raw only","func":"// organise the zone data\nrecv = {};\nrecv.raw = msg.payload;\n\n// create the payload for the HA event\nmsg.payload = {};\nmsg.payload.data = {};\nmsg.payload.data.recv = recv;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":920,"wires":[["b29887a1a73587b1"]]},{"id":"0f96929e6e115670","type":"function","z":"c9e6e970e7729a45","name":"P1P0","func":"// organise the zone data\nrecv = {};\nrecv.raw = msg.payload;\n\nzone = {};\nzone.power = 0;\n\nrecv[1] = zone;\n\n// creat the payload for the HA event\nmsg.payload = {};\nmsg.payload.data = {};\nmsg.payload.data.recv = recv;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":310,"y":840,"wires":[["b29887a1a73587b1"]]},{"id":"e4f47f6b164900ee","type":"function","z":"c9e6e970e7729a45","name":"P2P0","func":"// organise the zone data\nrecv = {};\nrecv.raw = msg.payload;\n\nzone = {};\nzone.power = 0;\n\nrecv[2] = zone;\n\n// creat the payload for the HA event\nmsg.payload = {};\nmsg.payload.data = {};\nmsg.payload.data.recv = recv;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":310,"y":880,"wires":[["b29887a1a73587b1"]]},{"id":"f41510c7.a2386","type":"server","name":"Home Assistant","version":1,"legacy":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]