How to read a response from USB/RS485 dongle - is HA scrap for nothing?

I spent a long long time to get working communication between HA and /dev/ttyUSB0 device.
I want do a SIMPLE action : Send a command and receive a answer. Send a command isn’t a problem, but NOBODY was able help me how to receive a answer. It looks like that HA isn’t able receive a answer. If HA isn’t able do it, it’s scrap for nothing.

Is somebody has a working solution, PLEASE SHARE. I have a HA sw running on the Odroid.

Does anyone really know?

What does an answer look like? Is it just an ASCII string? You need some template to get/parse the response to a state like shown here Serial - Home Assistant

it’s hex formated answer like :
10H 01H FFH FFH 00H 60H 08H 02H 79H 7BH FFH
Answer is changing depends on the sent request which is also HEX
Not sure if it’s possible send command and receive answer directly from HA or is maybe necessary use a node red. But send is working.

So depending on what you want to know, use a set of templates for the values and possibly some conversion of Hex to known things. Based on what you have above, you are not parsing the response to anything. Or get the whole string of hex and parse to attributes in a tenplate.

No till now no parsing. As a first step I want to see, that answer was received. And this is my proble, I do not see any answer.

Because you are not getting the response, you have to put it into the state. It might be possible to set logging to debug and it show data returned, never tried that.

somethink like this ? :

  #serial port response
  - platform: serial
    serial_port: /dev/ttyUSB0
    name: usbtoRS485
    baudrate: 9600
  - platform: template
    sensors:
      usb_sensor:
        friendly_name: readusbtoRS485
        value_template: "{{ states('sensor.usbtoRS485') }}"

Possibly. I would need to look at other variables to see if you need to set doe two way. What does dev tools show you as that state of those?

so in the configuration.yaml I have this:

   
  #serial port response
  - platform: serial
    serial_port: /dev/ttyUSB0
    name: usbtoRS485
    baudrate: 9600
  - platform: template
    sensors:
      usb_sensor:
        friendly_name: readusbtoRS485
        value_template: "{{ states('sensor.usbtoRS485') }}"

shell_command:
    sendcommand: echo -en '\x10\x01\xFF\xFF\x10\x30\xF8\x02\xE3\x61\xFF' > /dev/ttyUSB0


and on the main screen I have for sending this button:

show_name: true
show_icon: false
type: button
name: TEST
icon_height: 4px
icon: ''
tap_action:
  action: call-service
  service: shell_command.sendcommand
  data: {}
  target: {}

and for receiving :

type: entity
entity: sensor.usb_sensor

when I click test button, no answer received, but I have connected also PC with second dongle with putty running and I can see, that HA sent a command and also answer was sent by external device.

Pleade define no answer is received. Where are you looking for an answer?

I’m looking on the main screen :
image

Neznámé = unknown
As first step I want see any answer anywhere. Than I can think about processing.

Look in logs for errors, look in history to see if something was sent.

Command was sent I can see via second dongle and PC connected which is listening communication. Also answer was sent but not received by HA (maybe received but don’t know where)

Not knowing home exactly things work, but have you tried without the second dongle and PC? Possibly it is eating the response and/or blocking the port as it is in use? I do not think two things can listen to the same port.

YES tested, no change, no answer received (displayed)

Did yo enable more detailed loggin like this:

logger:
  default: critical
  logs:
    homeassistant.components.sensor: debug
    homeassistant.components.serial: debug
    homeassistant.components.sensor.serial: debug

Restart an then test again and see what if any messages are in the logs

no message:

2022-09-03 19:35:34.547 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.integration
2022-09-03 19:35:34.547 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.integration
2022-09-03 19:35:34.548 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.serial
2022-09-03 19:35:34.616 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.hassio
2022-09-03 19:35:34.624 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.template
2022-09-03 19:35:34.626 INFO (MainThread) [homeassistant.components.serial.sensor] Serial device /dev/ttyUSB0 connected
2022-09-03 19:35:34.627 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.template
2022-09-03 19:35:34.629 DEBUG (MainThread) [homeassistant.components.sensor] Not adding entity Version because it's disabled
2022-09-03 19:35:34.629 DEBUG (MainThread) [homeassistant.components.sensor] Not adding entity Newest version because it's disabled
2022-09-03 19:35:34.630 DEBUG (MainThread) [homeassistant.components.sensor] Not adding entity CPU percent because it's disabled
2022-09-03 19:35:34.630 DEBUG (MainThread) [homeassistant.components.sensor] Not adding entity Memory percent because it's disabled
2022-09-03 19:35:34.630 DEBUG (MainThread) [homeassistant.components.sensor] Not adding entity Version because it's disabled
2022-09-03 19:35:34.630 DEBUG (MainThread) [homeassistant.components.sensor] Not adding entity Newest version because it's disabled
2022-09-03 19:35:39.572 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.energy
2022-09-03 19:35:39.593 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.modbus
2022-09-03 19:35:39.690 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.utility_meter
2022-09-03 19:35:39.690 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.utility_meter
2022-09-03 19:35:39.690 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.utility_meter
2022-09-03 19:35:39.690 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.utility_meter
2022-09-03 19:35:40.352 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.forecast_solar
2022-09-03 19:35:40.357 DEBUG (MainThread) [homeassistant.components.sensor] Not adding entity Estimated power production - next hour because it's disabled
2022-09-03 19:35:40.358 DEBUG (MainThread) [homeassistant.components.sensor] Not adding entity Estimated power production - next 12 hours because it's disabled
2022-09-03 19:35:40.358 DEBUG (MainThread) [homeassistant.components.sensor] Not adding entity Estimated power production - next 24 hours because it's disabled

Try adding shell_command to that logging and test again