Send a serial command and read the response as a sensor

The above does not read a response - just send a command ie. it’s one way.

Sorry, it’s not going to help you, but for completeness here is what I have done.
I have an arduino that I made a while back to decode IR and supply codes into the serial on the DAB (as the DAB1 IR would only control zone 1 - so stupid!).

The arduino plays a message broker/forwarder role - it takes in commands on the various serial and IR connections and sends them where they need to go. I made this in 2016 when i was using Domotiga, then moved to homeseer and now HA.

IR codes gets decoded by the arduino into DAB1 commands and sent to the DAB1 via Serial1
Commands from the PC come in on arduino Serial port 2 and are “forwarded” to the DAB1 serial port (Serial1)
Responses from the DAB1 come in on Serial1 and are sent out on the Arduino USB port

So I get “real time” status in HA regardless of using HA, remote, wall controller…and also get full IR control :slight_smile: of all zones from my all in one remote.

More than one way to skin an automation. A plugin would be better - but this does the job for me.

ok, please, could you be more specific how you read responses from your DAB over serial as sensors? Thank you.

Sure. here is my node red flow which handles the responses from the DAB1 one - only response comes in to this flow/serial port.

[{"id":"6ce4b00e8d09afee","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"b211fe56e25b7c93","type":"group","z":"6ce4b00e8d09afee","style":{"stroke":"#2e333a","stroke-opacity":"1","fill":"#383c45","fill-opacity":"0.5","label":true,"label-position":"nw","color":"#a4a4a4"},"nodes":["01bcc466fa23b3e0","d59c48e33e54f45d","e94c72bbe197029f","46d72bba39130ac2"],"x":554,"y":319,"w":732,"h":82},{"id":"01bcc466fa23b3e0","type":"serial in","z":"6ce4b00e8d09afee","g":"b211fe56e25b7c93","name":"DAB1","serial":"e8a148f5faaa14e4","x":630,"y":360,"wires":[["d59c48e33e54f45d"]]},{"id":"d59c48e33e54f45d","type":"function","z":"6ce4b00e8d09afee","g":"b211fe56e25b7c93","name":"Process return Code","func":"var r = msg.payload.toString()\nvar parts = r.split(\"+\"); // Response is preceded by a + symbol\nvar response = parts[1];  // This is the text after the + symbol\n\nmsg.topic  = \"\";\nmsg.payload = \"\";\nmsg.valid = \"no\";\n// use the second element:\nif(response.length >0){\n  var command = response.substr(0,1).trim();\n  var param1  = response.substr(1, 1).trim();\n  var param2;\n    \n  switch(command) {\n    case \"Z\": // Zone On/Off\n      if(response.length ==2){\n        msg.topic = \"DAB1/Power\";\n        msg.payload = param1;\n        msg.valid = \"yes\";\n      }\n      else {\n        param2 = response.substr(2, response.length-3).trim();\n        msg.topic = \"DAB1/PowerZone\" + param1;\n        msg.payload = param2;\n        msg.valid = \"yes\";\n      }\n    break;\n    case \"S\": //Source\n      param2    = response.substr(2, 1);\n      msg.topic  = \"DAB1/SourceZone\" + param1;\n      msg.payload = param2;\n      msg.valid = \"yes\";\n      break;\n    case \"R\": // Tuner Memory. Note this can be 0 to 12\n      param1 = response.substr(1, response.length-2).trim();\n      msg.topic  = \"DAB1/Station\";\n      msg.payload = param1;\n      msg.valid = \"yes\";\n      break;    \n    case \"N\": // Tuner Band\n      msg.topic= \"DAB1/Band\";\n      msg.payload = param1;\n      msg.valid = \"yes\";\n      break;  \n    case \"V\": // Volume\n      param2 = response.substr(2, response.length-3).trim();\n      msg.topic= \"DAB1/VolumeZone\" + param1;\n      msg.payload = param2;\n      msg.valid = \"yes\";\n      break;    \n    case \"G\": // Page Volume\n      param2 = response.substr(2, response.length-3).trim();\n      msg.topic= \"DAB1/PageVolumeZone\" + param1;\n      msg.payload = param2;\n      msg.valid = \"yes\";\n      break;\n    case \"M\": // Mute\n      param2 = response.substr(2, 1).trim();\n      msg.topic  = \"MuteZone\" + param1;\n      msg.payload = param2;\n      msg.valid = \"yes\";\n      break;\n    case \"B\": // Balance Note: Param 2 can be -10 to +10\n      param2 = response.substr(2, response.length-3).trim();\n      msg.topic  = \"BalanceZone\" + param1;\n      msg.payload = param2;\n      msg.valid = \"yes\";\n      break;\n    case \"L\": // Bass\n      param2 = response.substr(2, response.length-3).trim();\n      msg.topic  = \"DAB1/BassZone\" + param1;\n      msg.payload = param2;\n      msg.valid = \"yes\";\n      break;\n    case \"T\": // Trebble\n      param2 = response.substr(2, response.length-3).trim();\n      msg.topic  = \"DAB1/TrebbleZone\" + param1;\n      msg.payload = param2;\n      msg.valid = \"yes\";\n      break;\n    default:\n      msg.topic  = \"DAB1/Failed\";\n  }\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":820,"y":360,"wires":[["e94c72bbe197029f"]]},{"id":"e94c72bbe197029f","type":"switch","z":"6ce4b00e8d09afee","g":"b211fe56e25b7c93","name":"","property":"valid","propertyType":"msg","rules":[{"t":"eq","v":"yes","vt":"str"},{"t":"neq","v":"yes","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1010,"y":360,"wires":[["46d72bba39130ac2"],[]]},{"id":"46d72bba39130ac2","type":"mqtt out","z":"6ce4b00e8d09afee","g":"b211fe56e25b7c93","name":"","topic":"","qos":"1","retain":"false","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"6b0783991fc336c8","x":1210,"y":360,"wires":[]},{"id":"e8a148f5faaa14e4","type":"serial-port","serialport":"/dev/serial/by-id/usb-Arduino__www.arduino.cc__0042_75439333535351306111-if00","serialbaud":"115200","databits":"8","parity":"none","stopbits":"1","waitfor":"","dtr":"none","rts":"none","cts":"none","dsr":"none","newline":"\\n","bin":"false","out":"char","addchar":"","responsetimeout":"10000"},{"id":"6b0783991fc336c8","type":"mqtt-broker","name":"HA MQTT","broker":"192.168.0.11","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""}]

And that feeds into MQTT sensors defined in the configuration.yaml ie…

 - platform: mqtt
    name: "DAB1_PowerZone3"
    state_topic: "DAB1/PowerZone3"

 - platform: mqtt
    name: "DAB1_VolumeZone3"
    state_topic: "DAB1/VolumeZone3"

Though - as I said - unless you have my setup (or similar splitting of the inbound and outbound serial traffic) it’s not much use. I also once did similar for a Tivo using Python so as I said, lots of ways to skin the home automation problem.

FWIW - here are my set of shell commands for the 3 zones I currently use. Ugly solution huh - but whatever - it works.

shell_command:
  set_19200_baud: stty -F /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0 19200
  dab1_am: echo -e ':N0\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_fm: echo -e ':N1\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_off_all: echo -e ':Z0\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_on_all: echo -e ':Z1\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_preset_1: echo -e ':R1\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_preset_2: echo -e ':R2\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_preset_3: echo -e ':R3\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_preset_4: echo -e ':R4\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_preset_5: echo -e ':R5\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_preset_6: echo -e ':R6\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_preset_7: echo -e ':R7\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_preset_8: echo -e ':R8\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_preset_9: echo -e ':R9\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_preset_10: echo -e ':R10\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_preset_11: echo -e ':R11\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_preset_12: echo -e ':R12\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone1_balancedown: echo -e ':B1--\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone1_balanceup: echo -e ':B1++\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone1_balanceup10: echo -e ':B1+10\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone1_balance0: echo -e ':B1-0\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone1_balancedown10: echo -e ':B1-10\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone1_trebledown: echo -e ':H1--\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone1_trebleup: echo -e ':H1++\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone1_trebleup10: echo -e ':H1+10\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone1_treble0: echo -e ':H1-0\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone1_trebledown10: echo -e ':H1-10\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone1_bassdown: echo -e ':L1--\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone1_bassup: echo -e ':L1++\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone1_bassup10: echo -e ':L1+10\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone1_bass0: echo -e ':L1-0\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone1_bassdown10: echo -e ':L1-10\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone1_mute_off: echo -e ':M10\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone1_mute_on: echo -e ':M11\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone1_mute_toggle: echo -e ':P1114\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone1_source1: echo -e ':S11\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone1_source2: echo -e ':S12\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone1_source3: echo -e ':S13\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone1_source4: echo -e ':S14\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone1_voldown: echo -e ':V1--\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone1_volup: echo -e ':V1++\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone1_vol10: echo -e ':V110\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone1_vol20: echo -e ':V120\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone1_vol30: echo -e ':V130\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone1_vol40: echo -e ':V140\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone1_off: echo -e ':Z10\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone1_on: echo -e ':Z11\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone2_balancedown: echo -e ':B2--\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone2_balanceup: echo -e ':B2++\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone2_balanceup10: echo -e ':B2+10\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone2_balance0: echo -e ':B2-0\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone2_balancedown10: echo -e ':B2-10\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone2_trebledown: echo -e ':H2--\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone2_trebleup: echo -e ':H2++\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone2_trebleup10: echo -e ':H2+10\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone2_treble0: echo -e ':H2-0\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone2_trebledown10: echo -e ':H2-10\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone2_bassdown: echo -e ':L2--\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone2_bassup: echo -e ':L2++\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone2_bassup10: echo -e ':L2+10\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone2_bass0: echo -e ':L2-0\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone2_bassdown10: echo -e ':L2-10\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone2_mute_off: echo -e ':M20\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone2_mute_on: echo -e ':M21\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone2_mute_toggle: echo -e ':P2114\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone2_source1: echo -e ':S21\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone2_source2: echo -e ':S22\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone2_source3: echo -e ':S23\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone2_source4: echo -e ':S24\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone2_voldown: echo -e ':V2--\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone2_volup: echo -e ':V2++\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone2_vol10: echo -e ':V210\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone2_vol20: echo -e ':V220\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone2_vol30: echo -e ':V230\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone2_vol40: echo -e ':V240\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone2_off: echo -e ':Z20\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone2_on: echo -e ':Z21\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone3_balancedown: echo -e ':B3--\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone3_balanceup: echo -e ':B3++\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone3_balanceup10: echo -e ':B3+10\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone3_balance0: echo -e ':B3-0\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone3_balancedown10: echo -e ':B3-10\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone3_trebledown: echo -e ':H3--\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone3_trebleup: echo -e ':H3++\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone3_trebleup10: echo -e ':H3+10\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone3_treble0: echo -e ':H3-0\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone3_trebledown10: echo -e ':H3-10\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone3_bassdown: echo -e ':L3--\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone3_bassup: echo -e ':L3++\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone3_bassup10: echo -e ':L3+10\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone3_bass0: echo -e ':L3-0\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone3_bassdown10: echo -e ':L3-10\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone3_mute_off: echo -e ':M30\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone3_mute_on: echo -e ':M31\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone3_mute_toggle: echo -e ':P3114\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone3_source1: echo -e ':S31\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone3_source2: echo -e ':S32\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone3_source3: echo -e ':S33\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone3_source4: echo -e ':S34\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone3_voldown: echo -e ':V3--\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone3_volup: echo -e ':V3++\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone3_vol10: echo -e ':V310\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone3_vol20: echo -e ':V320\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone3_vol30: echo -e ':V330\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone3_vol40: echo -e ':V340\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone3_off: echo -e ':Z30\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0
  dab1_zone3_on: echo -e ':Z31\x0D' > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9014HGD-if00-port0

Getting there :slight_smile:

1 Like

Hi Vahaldor,

I’m new to HA & Seems have the same question with this topic.

I’ve got a projector & also have the serial command code

My goals are:

  • Getting control with my projector (ex.Power on/off,Input Switch) & make a button on dashboard
  • Get the latest status (ex.Power) & show different color in dashboard when it change

But I don’t really know about the whole progress (step by step) will like ? :sweat_smile:

  • Make an entitie called projector and define the serial port?
  • Use the developer mode to do further progress?
  • The most important thing is “How to send the serial command” ?
  • Create a button on dashboard?

Hope can get some advice & many thanks :pray:

Hi Patrick,
welcome to rabbit hole! I see that Andrew found a way for reading stuff, I haven’t tried it yet.

I am changing state of buttons by using boolean helper. In fact, if you do not use the controller from 80s in 20th century, than you do not have other options how to change a state of a button, so booelan helper is enough. Then I have automations that triggers when the helper changes state and run scripts using the automations. Therefore, one button needs one input boolean and at least two automations (on>off, off>on).

I see that I explained it in detail on the link in the first post.

I want to use a resistance output to my Home Assistant and found a product that can generate a resistance output for many different RTDs.

Resistance output simulator for all standard RTD

However I am not that used to Home Assistant, what is the best way to integrate this?

I want to send serial AT commands to control the resistance, thus faking the outdoor or indoor temperature of my heating system, to make it run less when energy is expensive and more during lower priced.

Anyone have experience of integrating and controlling output devices with serial input?

Not to hijack your thread, how is that esacaped?
I’m trying to send at*smsm2m=“1112223333 message” to /dev/tty.usbmodem2101

I have not solved it yet but just asked ChatGPT and he came up with a neat idea how to achieve it (will try it when back home)

Yes, you can send a serial command and read the response in Home Assistant using the serial component. The serial component allows you to communicate with serial devices over a serial port.

To use the serial component, you will need to configure it in your configuration.yaml file. Here’s an example configuration:

serial:
  - port: /dev/ttyUSB0
    baudrate: 9600

In this example, we’re configuring the serial component to use the serial port /dev/ttyUSB0 and a baud rate of 9600. You’ll need to adjust the port and baudrate settings to match your device’s configuration.

Once you have the serial component configured, you can use the serial.write and serial.readline services to send commands and read responses. Here’s an example automation that sends a command and reads the response:

- alias: 'Serial Command'
  trigger:
    platform: state
    entity_id: input_boolean.serial_command
    to: 'on'
  action:
    - service: serial.write
      data:
        port: /dev/ttyUSB0
        message: 'COMMAND\r\n'
    - delay:
        milliseconds: 500
    - service: serial.readline
      data:
        port: /dev/ttyUSB0
      target:
        entity_id: sensor.serial_response

In this example, the automation is triggered by the state of an input boolean entity called input_boolean.serial_command. When the input boolean changes to on, the automation sends the command COMMAND\r\n to the serial device using the serial.write service. After a delay of 500 milliseconds, the automation reads a line of data from the serial device using the serial.readline service and stores the result in a sensor entity called sensor.serial_response.

You’ll need to adjust the port setting in both services to match your device’s configuration. You may also need to adjust the delay time depending on how quickly your device responds to commands.

Thank you for posting this! I am currently trying to do the same.

Unfortunately i cannot seem to get the serial service active.

I have added

serial:
  - port: /dev/ttyACM0
    baudrate: 115200

to my configuration.yaml file but calling serial.write from an automation returns that the service serial.write is unknown.

my automation looks like this:

alias: serial automation 
description: ""
trigger:
  - platform: state
    entity_id:
      - input_number.voltage_set
condition: []
action:
  - service: serial.write
    data:
      port: /dev/ttyACM0
      message: 'Meine Fresse'
mode: single

can you help me out? :slight_smile:
thanks!

Sorry for the confusion! I think that serial service does not exist in HA and ChatGPT simply made this idea out from his fantasy. I should have deleted the post

no worries. Found a solution:

I have an old Arcam serial amp and I send rest commands to control and node red to receive data back. I had no success with the serial integration so gave up.

ok but it seems that the shell command does not contain hex message, which is necessary e.g. in communicating with DPL projector. Am I missing something here? I need to ask a particular question to the DLP projector and then receive “1” or “0”

Do you mind posting a detailed description of how you achieved the objectives? Thanks

Sure, but I was mistaken about the rest commands. It is actually switches I used but I’m sure you could Rest as well

>     arcam_decode_plii_movie:
      command_on: 'echo -e "\x50\x43\x5f\x34\x31\x30\x0d" > /dev/ttyUSB0'
    arcam_decode_plii_music:
      command_on: 'echo -e "\x50\x43\x5f\x34\x31\x31\x0d" > /dev/ttyUSB0'
    arcam_decode_pliix_movie:
      command_on: 'echo -e "\x50\x43\x5f\x34\x31\x33\x0d" > /dev/ttyUSB0'
    arcam_decode_pliix_music:
      command_on: 'echo -e "\x50\x43\x5f\x34\x31\x34\x0d" > /dev/ttyUSB0'
    arcam_decode_neo6_cinema:
      command_on: 'echo -e "\x50\x43\x5f\x34\x31\x37\x0d" > /dev/ttyUSB0'
    arcam_decode_neo6_music:
      command_on: 'echo -e "\x50\x43\x5f\x34\x31\x38\x0d" > /dev/ttyUSB0'

The command I send is based on a the serial format for Arcam and I had to refer there for the details.
For sending volume changes, I use the shell command

>  /bin/bash -c "echo -e -n a='\x50\x43\x5f\x30\x31\x{{ '%0x' | format( states.input_number.arcam_volume.state | int + 0x30 ) | string }}\x0d' > /dev/ttyUSB0"

For responses I use Node Red as I haven’t found a method of receiving responses via HA.

> [{"id":"537ff01a.d5694","type":"tab","label":"Arcam Serial","disabled":false,"info":""},{"id":"44db0922d68e743c","type":"serial in","z":"537ff01a.d5694","name":"Arcam","serial":"9b6c3c03.9253f","x":110,"y":640,"wires":[["069ade71dffbeb06","7dfadfb3b9d2d04b","a886b1ec6801ec26","0e76b3690275815c"]]},{"id":"f4409487.fa405","type":"function","z":"537ff01a.d5694","name":"Convert volume to actual level","func":"let data = [...msg.payload]\ndata = data.map(hex => parseInt(hex));\ndata[6] = data[6] - 48; // or 0x30 or \"0x30\"\nmsg.payload = data;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":610,"y":480,"wires":[["5a12ef2665f015c4"]]},{"id":"5a12ef2665f015c4","type":"ha-entity","z":"537ff01a.d5694","name":"Send volume to HA","server":"cbd47e7957cb4d83","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Volume"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:volume-equal"},{"property":"unit_of_measurement","value":"dB"},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"state":"payload[6]","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"","outputPayloadType":"str","x":910,"y":480,"wires":[[]]},{"id":"069ade71dffbeb06","type":"switch","z":"537ff01a.d5694","name":"Check volume command","property":"payload[3]","propertyType":"msg","rules":[{"t":"eq","v":"0x2f","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":290,"y":480,"wires":[["f4409487.fa405"]]},{"id":"a886b1ec6801ec26","type":"switch","z":"537ff01a.d5694","name":"Check source input","property":"payload[3]","propertyType":"msg","rules":[{"t":"eq","v":"0x31","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":310,"y":680,"wires":[["1f89e1860f9973da"]]},{"id":"7dfadfb3b9d2d04b","type":"switch","z":"537ff01a.d5694","name":"Check display","property":"payload[3]","propertyType":"msg","rules":[{"t":"eq","v":"0x2b","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":320,"y":600,"wires":[["e882bdf78af02669"]]},{"id":"0b7236e323df4bdb","type":"switch","z":"537ff01a.d5694","name":"Check analogue or digital","property":"payload[4]","propertyType":"msg","rules":[{"t":"eq","v":"55","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":310,"y":760,"wires":[[]]},{"id":"126b50998dd5d87c","type":"function","z":"537ff01a.d5694","name":"function 1","func":"var rawData = msg.payload.toString(); // Convert the buffer to a string\n\n// Check if the received data is 8 characters long\nif (rawData.length === 8) {\n    // Split the string into pairs of two characters\n    var hexValues = rawData.match(/.{1,2}/g);\n\n    // Convert each pair from hexadecimal to decimal\n    var parsedData = hexValues.map(function (hex) {\n        return parseInt(hex, 16);\n    });\n\n    // Subtract 0x30 from the 7th sensor value\n    if (parsedData.length >= 7) {\n        parsedData[6] -= 0x30;\n    }\n\n    // Convert values to ASCII characters\n    var asciiData = parsedData.map(function (decimal) {\n        return String.fromCharCode(decimal);\n    });\n\n    // Send data to separate Home Assistant sensors\n    for (var j = 0; j < asciiData.length; j++) {\n        // Prepare individual sensor payload\n        var sensorPayload = {\n            payload: asciiData[j],\n            topic: \"homeassistant/sensor/sensor\" + (j + 1) + \"/state\"\n        };\n\n        // Send sensor data to Home Assistant\n        node.send(sensorPayload);\n    }\n} else {\n    // Handle error when the received data is not 8 characters long\n    msg.payload = 'Invalid data length';\n    node.error(msg.payload);\n}\n\nreturn null;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":200,"wires":[[]]},{"id":"e882bdf78af02669","type":"ha-entity","z":"537ff01a.d5694","name":"Send display value to HA","server":"cbd47e7957cb4d83","version":2,"debugenabled":true,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Arcam Display"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"state":"payload[6]","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"","outputPayloadType":"str","x":930,"y":580,"wires":[[]]},{"id":"1f89e1860f9973da","type":"ha-entity","z":"537ff01a.d5694","name":"Send input to HA","server":"cbd47e7957cb4d83","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Arcam Input"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"state":"payload[6]","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"","outputPayloadType":"str","x":910,"y":680,"wires":[[]]},{"id":"0e76b3690275815c","type":"switch","z":"537ff01a.d5694","name":"Check volume change command","property":"payload[3]","propertyType":"msg","rules":[{"t":"eq","v":"0x30","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":320,"y":540,"wires":[["f4409487.fa405"]]},{"id":"9b6c3c03.9253f","type":"serial-port","serialport":"/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_00000000-if00-port0","serialbaud":"38400","databits":"8","parity":"none","stopbits":"1","waitfor":"","dtr":"none","rts":"none","cts":"none","dsr":"none","newline":"0xd","bin":"bin","out":"char","addchar":"","responsetimeout":"10000"},{"id":"cbd47e7957cb4d83","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30"}]

It’s complex but just about works. The key thing is understanding the format your serial port uses and I can’t help you with that, I’m afraid.

I realize I’m a bit late to the party here, but I found this thread when searching for “serial request / response”, so for the sake of the search engines:

The solution I found was to use “tio”: GitHub - tio/tio: A simple serial device I/O tool This packages the send-then-receive into a simple call.

I’ve used this successfully in a simple serial wired gas meter sensor, see GitHub - m9aertner/SimpleSerialGas: Impulse Counter for my Gas meter with wired serial connection to HomeAssistant

- sensor:
  name: "Serial Gas"
  unique_id : s11111111-xxxx-yyyy-zzzz
  command: 'echo -e "Q:0\r" | tio -b 57600 /dev/serial/by-id/usb-Prolific_Technology_Inc._USB-Serial_Controller-if00-port0 --response-wait --response-timeout 300 | cut -d: -f3'
  unit_of_measurement: "m³"
  value_template: "{{ value | multiply(0.01) | round(2) }}"
  scan_interval: 30
2 Likes