MySensors sensor wont show in HA

I am trying to setup Home Assistant with MySensors. Current setup is Rpi 3 , W5100 Ethernet gateway with NRF24 radios. All communication seems fine but the sensor wont register. HA log shows Node ID 10 is unknown. Node ID 10 is a MySensors 2 Motion Sensor.

Here is my Gateway log

Here is my Sensor Log

http://pastebin.com/ntrF4RN5

How do I tell HA what node 10 is? The auto detection does not seem to be working for the Sensor. It does find my Roku device but that is all.

Motion Sensor Sketch

http://pastebin.com/P1yxiszH

Logs and sketch look fine. What does a debug level log from HA look like?

Hi Martin,

Thanks for your reply. I found a post from you that had some sample code in it about a gateway issue and I noticed I the mysensors platform id grouped with the default weather sensor instead of with the mysensors gateway section. Once I move that it identified the node correctly.

1 Like

Can this code be shared? Decided today to switch from pure MQTT (not mysensors mqtt) gateway setup to mysensors gateway (connected like ethernet gateway). But having some problems… Instead of two switches get only one

Got the following. But as can be seen from below code - have two of them

switch.vent_klapans_56_7	on	device: 127.0.0.1
V_LIGHT: on
child_id: 7
description: 
node_id: 56
friendly_name: Vent Klapans 56 7
assumed_state: false
battery_level: 0

Node code

#define SN "Vent Klapans"
#define SV "2.1"

//System settings
#define MY_NODE_ID 56
#define MY_RADIO_NRF24
#define MY_DEBUG

#include <Bounce2.h>
#include <DHT.h>
#include <math.h>
#include <MySensors.h>
#include <SPI.h>
#include <Wire.h>

//SETUP PINS
#define BUT1_PIN 7
#define BUTTON_PIN2 8 
#define DHT_PIN 3
#define RELAY_1  5  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
#define NUMBER_OF_RELAYS 2 // Total number of attached relays

//Define connections
#define CHILD_ID_HUM 3
#define CHILD_ID_TEMP 4
#define CHILD_BUT1_ID 7
#define CHILD_BUT2 8

#define RELAY_ON 0  // GPIO value to write to turn on attached relay
#define RELAY_OFF 1 // GPIO value to write to turn off attached relay
DHT dht;

//MQ+DHT
long DHT_Millis = 0;
long DHT_interval = 60000;
//Buttons
Bounce debouncer1 = Bounce(); 
Bounce debouncer_2 = Bounce();
int oldValue1=-1;
int oldValue_2=-1;
bool state1;
bool state2;

MyMessage msgHumi(CHILD_ID_HUM, V_HUM);
MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
MyMessage msgBut1(CHILD_BUT1_ID,V_STATUS);
MyMessage msgbut2(CHILD_BUT2,V_TRIPPED);

void before() 
{
  dht.setup(DHT_PIN);
  pinMode(BUT1_PIN,INPUT_PULLUP);
  pinMode(BUTTON_PIN2,INPUT);
  digitalWrite(BUTTON_PIN2, HIGH);
  debouncer1.attach(BUT1_PIN);
  debouncer1.interval(5);
  debouncer_2.attach(BUTTON_PIN2);
  debouncer_2.interval(5);
  for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) // Fetch relay status
    {   
    pinMode(pin, OUTPUT);   // Then set relay pins in output mode
    digitalWrite(pin, loadState(sensor)?RELAY_ON:RELAY_OFF); // Set relay to last known state (using eeprom storage) 
    }
} 
void setup()  
{  Serial.begin(115200); }
void presentation()  
{ 
  sendSketchInfo(SN, SV);
  present(CHILD_ID_HUM, S_HUM);
  present(CHILD_ID_TEMP, S_TEMP);
  present(CHILD_BUT1_ID, S_LIGHT); 
  present(CHILD_BUT2, S_DOOR);
  for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) // Fetch relay status
    {
    present(sensor, S_LIGHT); // Register all sensors to gw (they will be created as child devices)
    }
}



void loop() 
{
  int value_but_2 = debouncer_2.read();
  unsigned long DHT_Current_Millis = millis();
  if(DHT_Current_Millis - DHT_Millis > DHT_interval)
  {
    DHT_Millis = DHT_Current_Millis; 
    delay(dht.getMinimumSamplingPeriod());
    float temperature = dht.getTemperature();
    float humidity = dht.getHumidity();
    if (isnan(temperature)) 
      {
      Serial.println("Failed reading temperature from DHT");
      } 
      if (isnan(humidity)) 
      {
      Serial.println("Failed reading humidity from DHT");
      }       
    else
      {
      send(msgTemp.set(temperature, 1));
      send(msgHumi.set(humidity, 1));
      Serial.print("T: ");
      Serial.println(temperature);
      Serial.print("H: ");
      Serial.println(humidity);
      }
  }
    debouncer1.update();
      int value = debouncer1.read();
      if (value != oldValue1) 
      {
        // Send in the new value
        send(msgBut1.set(value==HIGH ? 1 : 0));
        oldValue1 = value;
      }
    debouncer_2.update();
    if (value_but_2 != oldValue_2) 
    { 
    if ( value_but_2==0)
      {
      state2 = !state2;
      send(msgbut2.set(state2));
      }
    oldValue_2 = value_but_2;
  }
}   
void receive(const MyMessage &message) 
{
    if (message.type==V_STATUS) // We only expect one type of message from controller. But we better check anyway.
      {
      digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF); // Change relay state
      saveState(message.sensor, message.getBool()); // Store state in eeprom
      Serial.print("Incoming change for sensor:"); // Write some debug info
      Serial.print(message.sensor);
      Serial.print(", New status: ");
      Serial.println(message.getBool());
      }

Your sketch doesn’t seem to send any values for the two relays. Each device needs to send at least one initial value to be added to home assistant.

PS: your sketch contains six children in total. 1 temp, 1 humidity, 2 buttons (1 S_DOOR, 1 S_LIGHT) and 2 relays (2 S_LIGHT). The switch you showed attributes for is the second button child.

Ok got that for relays. But what about the sensors? Considering they are constantly updating their status - shouldn’e i see them after an update?

I would need to see debug logs from home assistant and your arduino, to try to answer that.