mysensors regularly disconnect from HA



  • I’ve been using Home Assistant for a while now and have a couple of mysensors temperature/humidity sensors connected to the mysensors integration via a Wi-Fi gateway. Every so often, maybe once every one or two weeks the sensors stop communicating with HA. I use the reload command in the mysensors integration and they start working again. This was not too much of an issue, but I have a pulse meter measuring my energy consumption now and I don’t really want gaps in this data.
    Any idea how I can trouble shoot this issue?



  • @keithellis If reloading the integration from within HA can "fix" the issue at least temporarily, I assume that the log should at least give a clue on this. So the best way to troubleshoot such issues may be to activate debug logging in the HA MySensors integrations and consult the logs when the communication stops.

    You may also try to remotely read (and store) the WiFi gateway serial output with a library like MyNetDebug.



  • @BearWithBeard Big thank you for the link to MyNetDebug. I was not aware of this debug feature. Looks cool, I will give it a try.



  • @BearWithBeard thank you, I’ll investigate further.



  • @BearWithBeard I've enabled the logging, I'll have to wait for it to drop off now, to see what it shows. Thanks for the info.



  • @BearWithBeard Ok, mysensors have just disconnected from HA again today. This is the last few lines of the log

    2021-10-08 01:26:58 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 6 child 1
    2021-10-08 01:26:58 DEBUG (MainThread) [mysensors.transport] Receiving 6;2;1;0;1;67
    2021-10-08 01:26:58 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 6 child 2
    2021-10-08 01:26:58 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: Sensebender Micro 6 1: value_type 0, value = 20.8
    2021-10-08 01:26:58 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: Sensebender Micro 6 2: value_type 1, value = 67
    2021-10-08 01:26:59 DEBUG (MainThread) [mysensors.transport] Receiving 3;0;1;0;1;83.6
    2021-10-08 01:26:59 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 3 child 0
    2021-10-08 01:26:59 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: TemperatureAndHumidity 3 0: value_type 1, value = 83.6
    2021-10-08 01:27:01 DEBUG (MainThread) [mysensors.transport] Receiving 9;1;1;0;17;256
    2021-10-08 01:27:01 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 9 child 1
    2021-10-08 01:27:01 DEBUG (MainThread) [mysensors.transport] Receiving 9;1;1;0;24;266854
    2021-10-08 01:27:01 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 9 child 1
    2021-10-08 01:27:01 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: Energy Meter 9 1: value_type 24, value = 266854
    2021-10-08 01:27:01 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: Energy Meter 9 1: value_type 18, value = 266.8530
    2021-10-08 01:27:01 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: Energy Meter 9 1: value_type 17, value = 256
    2021-10-08 01:27:01 DEBUG (MainThread) [mysensors.transport] Receiving 9;1;1;0;18;266.8540
    2021-10-08 01:27:01 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 9 child 1
    2021-10-08 01:27:01 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: Energy Meter 9 1: value_type 24, value = 266854
    2021-10-08 01:27:01 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: Energy Meter 9 1: value_type 18, value = 266.8540
    2021-10-08 01:27:01 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: Energy Meter 9 1: value_type 17, value = 256
    2021-10-08 01:27:05 DEBUG (SyncWorker_0) [mysensors.persistence] Saving sensors to persistence file /mnt/data/dietpi_userdata/homeassistant/mysensors.json
    2021-10-08 01:27:07 DEBUG (MainThread) [mysensors.transport] Sending 0;255;3;0;2;
    2021-10-08 01:27:07 DEBUG (MainThread) [mysensors.transport] Receiving 0;255;3;0;2;2.3.2
    2021-10-08 01:27:13 DEBUG (MainThread) [mysensors.gateway_tcp] Connection lost with <_SelectorSocketTransport closing fd=78 read=idle write=<idle, bufsize=0>>
    

    Looks like it was all working well up until the last line, then the socket closed. If you can help me understand what is going on, that would be great.

    I grep'ed the log for "mysensors", so if this has missed any important information please let me know and I can have another look.
    Thanks,



  • @keithellis This is the log after I reload the integration in HA. Don't know if this is useful.

    2021-10-08 17:31:21 DEBUG (MainThread) [homeassistant.components.mysensors.device.Energy Meter 8 1] deleted ('5629f2f7535b66d050ad7d9cbd60e936', 8, 1, 17) from platform sensor
    2021-10-08 17:31:21 DEBUG (MainThread) [homeassistant.components.mysensors.device.Energy Meter 8 1] deleted ('5629f2f7535b66d050ad7d9cbd60e936', 8, 1, 18) from platform sensor
    2021-10-08 17:31:21 DEBUG (MainThread) [homeassistant.components.mysensors.device.TemperatureAndHumidity 4 0] deleted ('5629f2f7535b66d050ad7d9cbd60e936', 4, 0, 1) from platform sensor
    2021-10-08 17:31:21 DEBUG (MainThread) [homeassistant.components.mysensors.device.TemperatureAndHumidity 4 1] deleted ('5629f2f7535b66d050ad7d9cbd60e936', 4, 1, 0) from platform sensor
    2021-10-08 17:31:21 DEBUG (MainThread) [homeassistant.components.mysensors.device.Sensebender Micro 6 1] deleted ('5629f2f7535b66d050ad7d9cbd60e936', 6, 1, 0) from platform sensor
    2021-10-08 17:31:21 DEBUG (MainThread) [homeassistant.components.mysensors.device.Sensebender Micro 6 2] deleted ('5629f2f7535b66d050ad7d9cbd60e936', 6, 2, 1) from platform sensor
    2021-10-08 17:31:21 DEBUG (MainThread) [homeassistant.components.mysensors.device.TemperatureAndHumidity 3 0] deleted ('5629f2f7535b66d050ad7d9cbd60e936', 3, 0, 1) from platform sensor
    2021-10-08 17:31:21 DEBUG (MainThread) [homeassistant.components.mysensors.device.TemperatureAndHumidity 3 1] deleted ('5629f2f7535b66d050ad7d9cbd60e936', 3, 1, 0) from platform sensor
    2021-10-08 17:31:21 DEBUG (MainThread) [homeassistant.components.mysensors.device.Energy Meter 9 1] deleted ('5629f2f7535b66d050ad7d9cbd60e936', 9, 1, 17) from platform sensor
    2021-10-08 17:31:21 DEBUG (MainThread) [homeassistant.components.mysensors.device.Energy Meter 9 1] deleted ('5629f2f7535b66d050ad7d9cbd60e936', 9, 1, 18) from platform sensor
    2021-10-08 17:31:21 INFO (MainThread) [mysensors.task] Stopping gateway
    2021-10-08 17:31:21 DEBUG (SyncWorker_3) [mysensors.persistence] Loading sensors from persistence file /mnt/data/dietpi_userdata/homeassistantmysensors.json
    2021-10-08 17:31:21 INFO (MainThread) [homeassistant.components.climate] Setting up climate.mysensors
    2021-10-08 17:31:21 INFO (MainThread) [homeassistant.components.cover] Setting up cover.mysensors
    2021-10-08 17:31:21 INFO (MainThread) [homeassistant.components.light] Setting up light.mysensors
    2021-10-08 17:31:21 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.mysensors
    2021-10-08 17:31:21 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.mysensors
    2021-10-08 17:31:21 INFO (MainThread) [homeassistant.components.switch] Setting up switch.mysensors
    2021-10-08 17:31:21 DEBUG (SyncWorker_2) [mysensors.persistence] Saving sensors to persistence file /mnt/data/dietpi_userdata/homeassistant/mysensors.json
    2021-10-08 17:31:21 DEBUG (MainThread) [homeassistant.components.mysensors.helpers] Node 0 is missing sketch name
    2021-10-08 17:31:21 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] discovering persistent devices: defaultdict(<class 'list'>, {'sensor': [('5629f2f7535b66d050ad7d9cbd60e936', 8, 1, 17), ('5629f2f7535b66d050ad7d9cbd60e936', 8, 1, 18), ('5629f2f7535b66d050ad7d9cbd60e936', 4, 0, 1), ('5629f2f7535b66d050ad7d9cbd60e936', 4, 1, 0), ('5629f2f7535b66d050ad7d9cbd60e936', 6, 1, 0), ('5629f2f7535b66d050ad7d9cbd60e936', 6, 2, 1), ('5629f2f7535b66d050ad7d9cbd60e936', 3, 0, 1), ('5629f2f7535b66d050ad7d9cbd60e936', 3, 1, 0), ('5629f2f7535b66d050ad7d9cbd60e936', 9, 1, 17), ('5629f2f7535b66d050ad7d9cbd60e936', 9, 1, 18)]})
    2021-10-08 17:31:21 DEBUG (MainThread) [homeassistant.components.mysensors.helpers] Discovering platform sensor with devIds: [('5629f2f7535b66d050ad7d9cbd60e936', 8, 1, 17), ('5629f2f7535b66d050ad7d9cbd60e936', 8, 1, 18), ('5629f2f7535b66d050ad7d9cbd60e936', 4, 0, 1), ('5629f2f7535b66d050ad7d9cbd60e936', 4, 1, 0), ('5629f2f7535b66d050ad7d9cbd60e936', 6, 1, 0), ('5629f2f7535b66d050ad7d9cbd60e936', 6, 2, 1), ('5629f2f7535b66d050ad7d9cbd60e936', 3, 0, 1), ('5629f2f7535b66d050ad7d9cbd60e936', 3, 1, 0), ('5629f2f7535b66d050ad7d9cbd60e936', 9, 1, 17), ('5629f2f7535b66d050ad7d9cbd60e936', 9, 1, 18)]
    2021-10-08 17:31:21 INFO (MainThread) [homeassistant.components.mysensors] Adding new devices: [<Entity Energy Meter 8 1>, <Entity Energy Meter 8 1>, <Entity TemperatureAndHumidity 4 0>, <Entity TemperatureAndHumidity 4 1>, <Entity Sensebender Micro 6 1>, <Entity Sensebender Micro 6 2>, <Entity TemperatureAndHumidity 3 0>, <Entity TemperatureAndHumidity 3 1>, <Entity Energy Meter 9 1>, <Entity Energy Meter 9 1>]
    2021-10-08 17:31:21 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: Energy Meter 8 1: value_type 24, value = 149
    2021-10-08 17:31:21 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: Energy Meter 8 1: value_type 18, value = 0.1490
    2021-10-08 17:31:21 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: Energy Meter 8 1: value_type 17, value = 758
    2021-10-08 17:31:21 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: Energy Meter 8 1: value_type 24, value = 149
    2021-10-08 17:31:21 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: Energy Meter 8 1: value_type 18, value = 0.1490
    2021-10-08 17:31:21 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: Energy Meter 8 1: value_type 17, value = 758
    2021-10-08 17:31:21 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: TemperatureAndHumidity 4 0: value_type 1, value = 93.4
    2021-10-08 17:31:21 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: TemperatureAndHumidity 4 1: value_type 0, value = 19.2
    2021-10-08 17:31:21 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: Sensebender Micro 6 1: value_type 0, value = 20.8
    2021-10-08 17:31:21 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: Sensebender Micro 6 2: value_type 1, value = 67
    2021-10-08 17:31:21 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: TemperatureAndHumidity 3 0: value_type 1, value = 83.6
    2021-10-08 17:31:21 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: TemperatureAndHumidity 3 1: value_type 0, value = 18.7
    2021-10-08 17:31:21 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: Energy Meter 9 1: value_type 24, value = 266854
    2021-10-08 17:31:21 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: Energy Meter 9 1: value_type 18, value = 266.8540
    2021-10-08 17:31:21 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: Energy Meter 9 1: value_type 17, value = 256
    2021-10-08 17:31:21 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: Energy Meter 9 1: value_type 24, value = 266854
    2021-10-08 17:31:21 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: Energy Meter 9 1: value_type 18, value = 266.8540
    2021-10-08 17:31:21 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: Energy Meter 9 1: value_type 17, value = 256
    2021-10-08 17:31:21 INFO (MainThread) [mysensors.gateway_tcp] Trying to connect to ('192.168.54.25', 5003)
    2021-10-08 17:31:22 INFO (MainThread) [mysensors.transport] Connected to <_SelectorSocketTransport fd=46 read=idle write=<idle, bufsize=0>>
    2021-10-08 17:31:22 DEBUG (MainThread) [mysensors.transport] Receiving 0;255;3;0;14;Gateway startup complete.
    2021-10-08 17:31:22 INFO (MainThread) [mysensors.handler] n:0 c:255 t:3 s:14 p:Gateway startup complete.
    2021-10-08 17:31:22 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 0 child 255
    2021-10-08 17:31:22 DEBUG (MainThread) [mysensors.transport] Sending 255;255;3;0;20;
    2021-10-08 17:31:22 DEBUG (MainThread) [mysensors.transport] Receiving 0;255;0;0;18;2.3.2
    2021-10-08 17:31:22 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 0 child 255
    2021-10-08 17:31:22 DEBUG (MainThread) [mysensors.transport] Receiving 9;255;3;0;21;0
    2021-10-08 17:31:22 DEBUG (MainThread) [mysensors.transport] Receiving 9;1;1;0;17;463
    2021-10-08 17:31:22 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 9 child 1
    2021-10-08 17:31:22 DEBUG (MainThread) [mysensors.transport] Receiving 9;1;1;0;24;277598
    2021-10-08 17:31:22 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 9 child 1
    2021-10-08 17:31:22 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: Energy Meter 9 1: value_type 24, value = 277598
    2021-10-08 17:31:22 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: Energy Meter 9 1: value_type 18, value = 266.8540
    2021-10-08 17:31:22 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: Energy Meter 9 1: value_type 17, value = 463
    2021-10-08 17:31:22 DEBUG (MainThread) [mysensors.transport] Receiving 9;1;1;0;18;277.5980
    2021-10-08 17:31:22 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 9 child 1
    2021-10-08 17:31:22 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: Energy Meter 9 1: value_type 24, value = 277598
    2021-10-08 17:31:22 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: Energy Meter 9 1: value_type 18, value = 277.5980
    2021-10-08 17:31:22 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: Energy Meter 9 1: value_type 17, value = 463
    
    

    Some of these sensors do not exist any more, for example Energy Meter 8 1



  • Hmmm. Unfortunately, that "connection lost" line is to vague for me to draw any conclusions.

    Have you had a chance to look at the gateway's serial log when it lost connection to Home Assistant?

    What version of MySensors are you running by the way? Maybe it's worthwhile to upgrade to 2.3.2 if it isn't already. Home Assistant is also up to date?

    The next steps that I would take would be to ...

    • Check that both MySensors and Home Assistant are on a recent version
    • Watch the gateway serial log for any hints (using a remote debugging library or hooking it up to a server / RPI and writing the serial output to a file)
    • Ensure that the power supply is fine and maybe even replace it temporarily, just in case
    • Consider adapting the gateway sketch to MQTT (or even serial) and see if the issue still comes up


  • @BearWithBeard thank you, that gives me a few things to try.



  • @keithellis , I had similar issues with my setup although I didn't investigate it in any kind of detail like suggested above, my solution was simply changing the WiFi network. I was having intermittent connectivity issues with a number of ESP8266/ESP32 devices on my mixed 2.4Ghz/5Ghz Mesh network, so I switched back on my routers WiFi in 2.4ghz mode only and named its SSID "WiFi-IOT" and connected all of these ESP based IOT devices to it and I've had no dropouts since.

    I have 4 MySensors gateways connected to Home Assistant, 2 by WiFi using an ESP8266 and an ESP32, the other 2 are Pi Zeros with 4G Hats connected by a VPN, since surprisingly I never had connectivity issues with the 2 remote devices and always the 2 WiFi ones literally next to the router I could only suspect the WiFi network. It may not be your issue but worth considering just the same. I think I will probably convert mine to serial gateways when I get the time.



  • @FarmerEd @BearWithBeard I tried to re-flash the wifi gateway, but it appears I am now stuffed. Apparently it is no longer possible to flash MySensors onto an ESP8266. Where to go now? It is possible to integrate NRF240L01 with a ESPHome gateway?



  • @keithellis flashing onto an esp8266 is still possible, but you have to make sure you use an earlier esp8266 package, below 3.0 IIRC.
    Compiling mysensors will give you an error probably, search on it in the forum and you will find more people with the same issue. And how to solve it



  • @electrik Yes I've found this post, but to be honest I don't no how to change the ESP8266 core. I'm flashing with the Arduino IDE and have used the ESP8266 Community Board. Is using version 2.7.4 of this board manager the same as using a v2 core?



  • @keithellis I think I've got it refreshed now. So lets see if this fixes my disconnection issues. thanks all.



  • I'm still getting this error on mysensors gate upgraded to 2.3.2.

    @BearWithBeard said in mysensors regularly disconnect from HA:

    Have you had a chance to look at the gateway's serial log when it lost connection to Home Assistant?

    No this is on my list to do.

    What version of MySensors are you running by the way? Maybe it's worthwhile to upgrade to 2.3.2 if it isn't already. Home Assistant is also up to date?

    HA is 2010.09.0, I can't upgrade further until I upgrade to Debian Bullseye
    Mysensors gateway is running 2.3.2, some nodes are slightly older.

    The next steps that I would take would be to ...

    • Check that both MySensors and Home Assistant are on a recent version

    Done

    • Watch the gateway serial log for any hints (using a remote debugging library or hooking it up to a server / RPI and writing the serial output to a file)

    On my todo list.

    • Ensure that the power supply is fine and maybe even replace it temporarily, just in case

    Checked, all seems ok

    • Consider adapting the gateway sketch to MQTT (or even serial) and see if the issue still comes up

    Don't really want to do this, but will to as a last result once I've checked gateway serial log.



  • I've run into the same issue with HA using ethernet. I believe it's an issue with the MySensors HA integration and their reconnect logic.

    I've had better luck with Serial and MQTT.



  • Same issue here. HA receives data from Ethernet Gateway for only a few minutes and then:

    DEBUG (MainThread) [mysensors.gateway_tcp] Connection lost with <_SelectorSocketTransport closing fd=42 read=idle write=<idle, bufsize=0>>
    

    I also have MYSController connected to the GW and it remains connected. There is an open issue as others are also having the same problem. Am wondering if anyone here is having success with Ethernet Gateway connected to HA.


Log in to reply
 

Suggested Topics

13
Online

11.4k
Users

11.1k
Topics

112.7k
Posts