Node 0 unknown, error decoding message from gateway
-
Hey guys,
I have just set up the gateway (also running a DHT22 sensor on the same arduino) in home-assistent and I keep getting the following errors:
16-12-16 16:49:38 mysensors.mysensors: Node 0 is unknown 16-12-16 16:49:38 mysensors.mysensors: Error decoding message from gateway, bad data received: T: 23.00
My config looks like the following:
mysensors: gateways: - device: '/dev/ttyACM0' # persistence_file: 'path/mysensors2.json' baud_rate: 115200 debug: true optimistic: false persistence: true retain: true version: 2.0
As you can see above, the values are received which is great.
Any idea how to solve that?
-
There's a bug in mysensors 2.0 where a gateway without radio doesn't present itself. This has been fixed in the mysensors dev branch. See this issue for more info and a workaround:
https://github.com/theolind/pymysensors/issues/51
-
This post is deleted!
-
Now it's not about the node 0 but the children.
16-12-17 11:39:31 mysensors.mysensors: Child 1 is unknown 16-12-17 11:39:31 mysensors.mysensors: Error decoding message from gateway, bad data received: T: 22.50 16-12-17 11:39:31 mysensors.mysensors: Child 0 is unknown 16-12-17 11:39:31 mysensors.mysensors: Error decoding message from gateway, bad data received: H: 40.20
The serial monitor shows me the following:
0;255;3;0;9;Starting gateway (R-NGA-, 2.0.0) 0;255;3;0;14;Gateway startup complete. 0;255;0;0;18;2.0.0 0;255;3;0;9;No registration required 0;255;3;0;9;Init complete, id=0, parent=0, distance=0, registration=1 0;1;1;0;0;23.2 T: 23.20 0;0;1;0;1;44.5 H: 44.50 0;0;1;0;1;44.4
Is anything wrong with my sketch? I hacked it together...
// Enable debug prints #define MY_DEBUG // Enable and select radio type attached //#define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 //#define MY_RS485 // Enable serial gateway #define MY_GATEWAY_SERIAL // Define a lower baud rate for Arduino's running on 8 MHz (Arduino Pro Mini 3.3V & SenseBender) #if F_CPU == 8000000L #define MY_BAUD_RATE 38400 #endif // Flash leds on rx/tx/err #define MY_LEDS_BLINKING_FEATURE // Set blinking period #define MY_DEFAULT_LED_BLINK_PERIOD 300 // Inverses the behavior of leds //#define MY_WITH_LEDS_BLINKING_INVERSE // Enable inclusion mode #define MY_INCLUSION_MODE_FEATURE // Enable Inclusion mode button on gateway #define MY_INCLUSION_BUTTON_FEATURE // Inverses behavior of inclusion button (if using external pullup) //#define MY_INCLUSION_BUTTON_EXTERNAL_PULLUP // Set inclusion mode duration (in seconds) #define MY_INCLUSION_MODE_DURATION 60 // Digital pin used for inclusion mode button #define MY_INCLUSION_MODE_BUTTON_PIN 3 // Uncomment to override default HW configurations //#define MY_DEFAULT_ERR_LED_PIN 4 // Error led pin #define MY_DEFAULT_RX_LED_PIN 11 // Receive led pin //#define MY_DEFAULT_TX_LED_PIN 5 // the PCB, on board LED #define MY_DEBUG #include <SPI.h> #include <MySensors.h> #include <DHT.h> // Set this to the pin you connected the DHT's data pin to #define DHT_DATA_PIN 3 // Set this offset if the sensor has a permanent small offset to the real temperatures #define SENSOR_TEMP_OFFSET 0 // Sleep time between sensor updates (in milliseconds) // Must be >1000ms for DHT22 and >2000ms for DHT11 static const uint64_t UPDATE_INTERVAL = 2500; // Force sending an update of the temperature after n sensor reads, so a controller showing the // timestamp of the last update doesn't show something like 3 hours in the unlikely case, that // the value didn't change since; // i.e. the sensor would force sending an update every UPDATE_INTERVAL*FORCE_UPDATE_N_READS [ms] static const uint8_t FORCE_UPDATE_N_READS = 10; #define CHILD_ID_HUM 0 #define CHILD_ID_TEMP 1 float lastTemp; float lastHum; uint8_t nNoUpdatesTemp; uint8_t nNoUpdatesHum; bool metric = true; MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); DHT dht; void presentation() { // Send the sketch version information to the gateway sendSketchInfo("TemperatureAndHumidity", "1.1"); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID_HUM, S_HUM); present(CHILD_ID_TEMP, S_TEMP); metric = getConfig().isMetric; } void setup() { present(255, 18); dht.setup(DHT_DATA_PIN); // set data pin of DHT sensor if (UPDATE_INTERVAL <= dht.getMinimumSamplingPeriod()) { Serial.println("Warning: UPDATE_INTERVAL is smaller than supported by the sensor!"); } // Sleep for the time of the minimum sampling period to give the sensor time to power up // (otherwise, timeout errors might occure for the first reading) sleep(dht.getMinimumSamplingPeriod()); } void loop() { // Force reading sensor, so it works also after sleep() dht.readSensor(true); // Get temperature from DHT library float temperature = dht.getTemperature(); if (isnan(temperature)) { Serial.println("Failed reading temperature from DHT!"); } else if (temperature != lastTemp || nNoUpdatesTemp == FORCE_UPDATE_N_READS) { // Only send temperature if it changed since the last measurement or if we didn't send an update for n times lastTemp = temperature; if (!metric) { temperature = dht.toFahrenheit(temperature); } // Reset no updates counter nNoUpdatesTemp = 0; temperature += SENSOR_TEMP_OFFSET; send(msgTemp.set(temperature, 1)); #ifdef MY_DEBUG Serial.print("T: "); Serial.println(temperature); #endif } else { // Increase no update counter if the temperature stayed the same nNoUpdatesTemp++; } // Get humidity from DHT library float humidity = dht.getHumidity(); if (isnan(humidity)) { Serial.println("Failed reading humidity from DHT"); } else if (humidity != lastHum || nNoUpdatesHum == FORCE_UPDATE_N_READS) { // Only send humidity if it changed since the last measurement or if we didn't send an update for n times lastHum = humidity; // Reset no updates counter nNoUpdatesHum = 0; send(msgHum.set(humidity, 1)); #ifdef MY_DEBUG Serial.print("H: "); Serial.println(humidity); #endif } else { // Increase no update counter if the humidity stayed the same nNoUpdatesHum++; } // Sleep for a while to save energy sleep(UPDATE_INTERVAL); }
-
Looks like presentation function is never called. Try calling it yourself from setup.
-
How would you do that? You can see my sketch above.
-
Put this after the gateway
present
call in setup:presentation();
Also replace all
sleep
withwait
. The gateway is not allowed to sleep.
-
@martinhjelmare said:
presentation();
I'll try that. Thanks.
Now this error remains:
16-12-17 21:58:00 mysensors.mysensors: Error decoding message from gateway, bad data received: T: 23.90 16-12-17 21:58:00 mysensors.mysensors: Error decoding message from gateway, bad data received: H: 49.30 16-12-17 21:58:02 mysensors.mysensors: Error decoding message from gateway, bad data received: T: 24.00 16-12-17 21:58:14 mysensors.mysensors: Error decoding message from gateway, bad data received: T: 23.90
But the sensors are listed in HASS:
sensor.temperatureandhumidity_0_0:
friendly_name: TemperatureAndHumidity 0 0 V_HUM: 49.2 node_id: 0 device: /dev/ttyACM0 battery_level: 0 description: child_id: 0 unit_of_measurement: %
-
That's because you are printing debug to serial from the gateway and the controller doesn't expect serial messages from the gateway other than mysensors API messages. Either ignore the errors or remove those debug prints.
-
@martinhjelmare thank you so much for your help.
Is there a way to declare sensor names so that HA receives a presentation with something like
mysensors.livingroom.temp
Instead of a more cryptic name with node_id?
-
The entity_id always has the same structure, sketchname_nodeid_childid. You can customize the friendly_name in the config under customize to change what is shown in the gui as name of the sensor.
-
But my Sketch name is SerialGateWayDHT22 and my sensors are called sensor.temperatureandhumidity_0_0 and sensor.temperatureandhumidity_0_1. If it was the Sketchname, it was much simpler to assign the sensors to the rooms later as I could simply name the switch after the room.
But it's not much of a problem, as like you said friendly names can be used.
-
By sketchname I mean what you send to the controller as sketchname using sendSketchInfo method. This is from your sketch:
// Send the sketch version information to the gateway sendSketchInfo("TemperatureAndHumidity", "1.1");
-
Just saw that myself. Thanks once again. I'm starting to feel embarrassed...
-
Happy to help and great to hear about user stories and also any feedback, both when things are working and when things are not working or missing features.
Suggested Topics
-
Hi,
Home Assistant • • diltech