[SOLVED] Mysensors nodes are not updating

Hi all,

I tried to find this on the forum (both here and @ MySensors) but could not find the answer. If it’s out there please apologize for asking (again).

I have connected my MySensors Ethernet gateway to HA. This was successful and the nodes are nicely appearing in the devices list. However none of my (currently 2) nodes is updating. The initial value is there, but is not updated. Can anyone give me a hint where to look.

Thx in advance,

Ralph

Configuration details:

HA: version 0.95.4. Running on Ubuntu 18.04 in Docker container

MySensors: version 2.1.1 Running on a Arduino Nano with Ethernet shield (so Ethernet version)

Post your arduino code.
Are you getting any mysensor errors in the HA log?

no, at first yes, but after tinkering with the mysensors settings everything looks fine.

And herewith the arduino code:

// Enable debug prints to serial monitor
// #include <MyConfig.h>
#define MY_DEBUG 

// Enable and select radio type attached
#define MY_RADIO_NRF24
//#define MY_RF24_CHANNEL	1
//#define MY_DEBUG_VERBOSE_RF24

#include <MySensors.h>  
#include <BH1750.h>
#include <Wire.h>

// Node and sketch information
#define SKETCH_VER            "0.2"				    // Sketch version
#define SKETCH_NAME           "Lightsensor"		// Optional child sensor name
#define CHILD_ID              1					      // Id of the sensor child
#define CHILD_NAME            "Lightsensor"		// Optional child sensor name
#define NODE_REPEATER         false				    // Set true if a repeater node (i.e. always turned on)

// Sketch settings
BH1750 lightSensor;

// Input and output definitions
MyMessage msg(CHILD_ID, V_LEVEL);
MyMessage msgPrefix(CHILD_ID, V_UNIT_PREFIX);  // Custom unit message.

// Global vars
unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
uint16_t lastlux = 0;
bool initialValueSent = false;

void setup()
{ 
  lightSensor.begin();
}

void presentation()  {
  // Send the sketch version information to the gateway and Controller
  sendSketchInfo(SKETCH_NAME, SKETCH_VER);
  // Register all sensors to gateway (they will be created as child devices)
  present(CHILD_ID, S_LIGHT_LEVEL);
}

void loop()      
{     
  if (!initialValueSent) {
    Serial.println("Sending initial value");
    send(msgPrefix.set("custom_lux"));  // Set custom unit.
    send(msg.set(lastlux));
    // Serial.println("Requesting initial value from controller");
    // request(CHILD_ID, V_LEVEL);
    // wait(2000, C_SET, V_LEVEL);
    initialValueSent = true;    
  }
  
  uint16_t lux = lightSensor.readLightLevel();  // Get Lux value
  Serial.println(lux);
  if (lux != lastlux) {
    send(msg.set(lux));
    lastlux = lux;
  }
  sleep(SLEEP_TIME);
}

void receive(const MyMessage &message) {
  if (message.type == V_LEVEL) {
    if (!initialValueSent) {
      Serial.println("Receiving initial value from controller");
      initialValueSent = true;
    }
  }
}

I commented parts as the request does not seem to work. Never gets to setting intialValueSent to true.

Thx in advance.

As a side node: updates are sent by the Arduino. I see them in MYSController

So the ethernet gateway is getting updates, that’s a good sign. The sketch looks fine so everything should be working.

What does your mysensors configuration look like for homeassistant?

@ firstof9: Here is the HA configuration:

## MySensors gateway
mysensors:
  gateways:
    - device: !secret ip_mysensors
      # persistence_file: 'mysensors.json'
      nodes:
        2:
          name: Watermeter (MYS)
        4:
          name: 'Light sensor (test)'
  version: 2.1

Thx again for thinking with me on this.

Ralph

Ya all this is looking fine.

You could attempted turning on debuging for mysensors:

  1. under developer tools go to services
  2. select logger.set_level
  3. type in { "homeassistant.components.mysensors":"debug" }
  4. click call service

Start tailing your home-assistant.log and see if anything from mysensors is reporting.
Once you get some data you can reverse it by setting the logging back to warn

Just turned it on and restarted HA to see what happens.
This is the result:

2019-08-03 09:53:05 DEBUG (MainThread) [homeassistant.components.mysensors.helpers] Node 0 is missing sketch name

2019-08-03 09:53:05 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: Watermeter (MYS) 1: value_type 24, value = 1047118
2019-08-03 09:53:05 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: Watermeter (MYS) 1: value_type 35, value = 1047.118
2019-08-03 09:53:05 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: Light sensor (test) 1: value_type 37, value = 50

2019-08-03 09:53:08 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 0 child 255
2019-08-03 09:53:17 INFO (MainThread) [mysensors.handler] n:0 c:255 t:3 s:14 p:Gateway startup complete.
2019-08-03 09:53:17 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 0 child 255
2019-08-03 09:53:17 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 0 child 255

2019-08-03 09:53:22 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 4 child 1

2019-08-03 09:53:22 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: Light sensor (test) 1: value_type 37, value = 44

2019-08-03 09:53:31 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 2 child 1
2019-08-03 09:53:31 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 2 child 1
2019-08-03 09:53:31 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: Watermeter (MYS) 1: value_type 24, value = 1047433
2019-08-03 09:53:31 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: Watermeter (MYS) 1: value_type 35, value = 1047.433

So both sensors update basically twice at start-up. After that nothing comes in anymore.
No errors also, so the GW stays connected I assume.

Ralph

Try setting the mysensors package to debug log level too in the logger settings in configuration.yaml or by calling the log level service. Then we will see the serial messages sent and received too.

To do this on a running HA instance follow the steps as before but change
{ "homeassistant.components.mysensors":"debug" }
to
{ "mysensors":"debug" }

Done and finally some answers?:

2019-08-03 14:06:02 WARNING (MainThread) [homeassistant.components.owntracks.messages] Received unsupported message type: MessageClear.
2019-08-03 14:06:02 DEBUG (SyncWorker_1) [mysensors.persistence] Loading sensors from persistence file /config/mysensors1.pickle
2019-08-03 14:06:02 DEBUG (SyncWorker_7) [mysensors.persistence] Saving sensors to persistence file /config/mysensors1.pickle
2019-08-03 14:06:02 DEBUG (MainThread) [homeassistant.components.mysensors.helpers] Node 0 is missing sketch name
2019-08-03 14:06:02 INFO (MainThread) [homeassistant.components.mysensors] Adding new devices: [<Entity Light sensor (test) 1: None>, <Entity Watermeter (MYS) 1: None>]
2019-08-03 14:06:02 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: Watermeter (MYS) 1: value_type 24, value = 1047433
2019-08-03 14:06:02 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: Watermeter (MYS) 1: value_type 35, value = 1047.433
2019-08-03 14:06:02 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: Light sensor (test) 1: value_type 37, value = 44
2019-08-03 14:06:02 INFO (MainThread) [mysensors.gateway_tcp] Trying to connect to ('192.168.0.210', 5003)
2019-08-03 14:06:02 INFO (MainThread) [mysensors] Connected to <TCPTransport closed=False reading=False 0x55ea37b708f8>
2019-08-03 14:06:11 DEBUG (MainThread) [mysensors] Receiving 0;255;3;0;22;3510323093
2019-08-03 14:06:11 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 0 child 255
2019-08-03 14:06:12 DEBUG (SyncWorker_6) [mysensors.persistence] Saving sensors to persistence file /config/mysensors1.pickle
2019-08-03 14:06:12 DEBUG (MainThread) [mysensors] Sending 0;255;3;0;2;
2019-08-03 14:06:13 DEBUG (MainThread) [mysensors] Receiving 0;255;3;0;14;Gateway startup complete.
2019-08-03 14:06:13 INFO (MainThread) [mysensors.handler] n:0 c:255 t:3 s:14 p:Gateway startup complete.
2019-08-03 14:06:13 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 0 child 255
2019-08-03 14:06:13 DEBUG (MainThread) [mysensors] Sending 255;255;3;0;20;
2019-08-03 14:06:13 DEBUG (MainThread) [mysensors] Receiving 0;255;0;0;18;2.1.1
2019-08-03 14:06:13 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 0 child 255
2019-08-03 14:06:13 DEBUG (MainThread) [mysensors] Receiving 0;255;3;0;2;2.1.1
2019-08-03 14:06:14 DEBUG (MainThread) [mysensors] Receiving 2;255;3;0;21;0
2019-08-03 14:06:15 DEBUG (MainThread) [mysensors] Receiving 2;1;1;0;24;1047546
2019-08-03 14:06:15 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 2 child 1
2019-08-03 14:06:15 DEBUG (MainThread) [mysensors] Receiving 2;1;1;0;35;1047.546
2019-08-03 14:06:15 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 2 child 1
2019-08-03 14:06:15 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: Watermeter (MYS) 1: value_type 24, value = 1047546
2019-08-03 14:06:15 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: Watermeter (MYS) 1: value_type 35, value = 1047.546
2019-08-03 14:06:22 DEBUG (SyncWorker_1) [mysensors.persistence] Saving sensors to persistence file /config/mysensors1.pickle
2019-08-03 14:06:22 DEBUG (MainThread) [mysensors] Sending 0;255;3;0;2;
2019-08-03 14:06:22 DEBUG (MainThread) [mysensors] Receiving 0;255;3;0;2;2.1.1
2019-08-03 14:06:32 DEBUG (MainThread) [mysensors] Sending 0;255;3;0;2;
2019-08-03 14:06:32 DEBUG (MainThread) [mysensors] Receiving 0;255;3;0;2;2.1.1
2019-08-03 14:06:42 DEBUG (MainThread) [mysensors] Sending 0;255;3;0;2;
2019-08-03 14:06:42 DEBUG (MainThread) [mysensors] Receiving 0;255;3;0;2;2.1.1
2019-08-03 14:06:44 DEBUG (MainThread) [mysensors.gateway_tcp] Connection lost with <TCPTransport closed=False reading=False 0x55ea37b708f8>

The last line shows a connection lost. That can’t be good.

After this do you get any more mysensors logs at all?

As far as i’ve seen, No more logs at all.

Ok, and after this do you still get data in MYSController from the gateway?

Yes. Data is still coming in there. So it looks like something on the HA side imho.

You are able to ping the IP as well I assume?

This is a very odd issue, maybe upgrade MySensors to 2.3? :man_shrugging:

I’m not at home currently, but will try later today. Upgrade is in the planning ad well.

As followup: the IP-adress pings, so is also working at that layer.

I’m not sure my gateway times out it’s using ethernet, but HA always reconnects to it.
Only thing I can think of is the nano isn’t powerful enough to be a gateway?