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)
// 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.
You could attempted turning on debuging for mysensors:
under developer tools go to services
select logger.set_level
type in { "homeassistant.components.mysensors":"debug" }
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
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.
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?