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.
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.
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.
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.
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.
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