Ok.
First of all - still no joy. Can't get any communications from MySensors to homeassistant.
Trying to tackle this bottom up. Thought it might be an issue with PySerial, but that reads data OK from the serial port:
import serial as serial
print ("starting")
ser = serial.Serial (
port='COM4',
baudrate=115200,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS
)
ser.flushInput()
ser.flushOutput()
print("connected to: " + ser.portstr)
count=1
while True:
try:
data_raw = ser.readline()
print(data_raw)
except serial.SerialException:
print ("SERIAL ERROR")
exit(1)
This results in what is expected:
starting
connected to: COM4
b'0;0;3;0;14;Gateway startup complete.\n'
b'0;0;3;0;9;read: 1-1-0 s=2,c=1,t=23,pt=2,l=2:0\n'
b'1;2;1;0;23;0\n'
b'0;0;3;0;9;read: 1-1-0 s=1,c=1,t=0,pt=7,l=5:25.0\n'
b'1;1;1;0;0;25.0\n'
b'0;0;3;0;9;read: 1-1-0 s=0,c=1,t=1,pt=7,l=5:84.0\n'
b'1;0;1;0;1;84.0\n'
b'0;0;3;0;9;read: 1-1-0 s=3,c=1,t=16,pt=0,l=1:0\n'
b'1;3;1;0;16;0\n'
(this is a four sensor node - Temp, Humidity, light level and presence detection)
I am trying to test the pymysensors (mysensors.mysensors) and I believe that is where the situation may originate.
Basically, pymysensors just hangs there on calling gw.start() in the code below:
import mysensors.mysensors as mysensors
import logging
def event(type, nid):
print(type+" "+str(nid))
gw = mysensors.SerialGateway('COM4', event)
logging.warning("Created SerialGateway")
print (gw)
gw.start()
Trying to wrangle through the pymysensors code...Could it be the windows threading implementation (gw.start()) causing some type of hung access to the serial port? Unfortunately, no messages (print or logging) that I put in the pymysensors actually get printed out (maybe due to being in a background thread?