Hello,
I want to move from Domoticz to HA but I’m having some trouble.
I built my own controller. 3 pieces.
Connection over RS485 and output from this controller is: A06;19,5;977;58;0;1 → [name;temperature;pressure;humidity;switch1;switch2].
Configuration sensor:
`
-
platform: command_line
name: Humanidity BedRoom
scan_interval: 30
command: “python3 /config/script/1a.py a06+send”
value_template: ‘{{ value.split(";")[3] }}’
unit_of_measurement: “%” -
platform: command_line
name: Temperature BedRoom
scan_interval: 30
command: “python3 /config/script/1a.py a06+send”
value_template: ‘{{ value.split(";")[1] }}’
unit_of_measurement: “°C”
`
my program 1a.py
`
#!/usr/bin/python3
import serial
import time
import sys
s=serial.Serial(port=’/dev/ttyUSB0’,
baudrate=9600,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
timeout=0.1)
s.flushOutput()
s.flushInput()
s.flush()
if s.isOpen():
s.close()
s.open()
s.isOpen()
arg = str(sys.argv[1])
x=arg.encode() + b’\x0d’ + b’\x0a’
s.write(x)
print(x)
time.sleep(0.1)
while s.inWaiting() > 0:
text=s.read(size=100)
temp=text.decode()
print(temp)
time.sleep(2)
s.close()
`
Now the python program starts three times and the controller can’t respond that fast.
2022-01-22 19:28:17 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: list object has no element 2 when rendering ‘{{ value.split(";")[2] }}’
2022-01-22 19:28:17 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: list object has no element 3 when rendering ‘{{ value.split(";")[3] }}’
So, I need to know how to setup the HA to update sensor values and switch statutes with one bash script.
Second problem I have with switch and status, but first I want to set up sensors.
best regards.