I send send information from the controller to a sensor node
on that there are 4 light connect. al with different child id
controller sends the child id and and level signaal
how can i get the child id out of the message on the node
Wow, this was a lot of information at once
I'm going to go through the code tomorrow and actually figure out whats going on. I'm contemplating actually writing my own code, instead of relying on someone else's. Might make things easier (or harder ) but in the end i think i might benefit from it.
i changed the code i had with the changes you suggested, and i can see the messages coming through to the gateway, but i still can't actually get home-assistant to display them. Trying to figure out if it's the code on the sensor, the code on the gateway or somewhere in-between that the message gets lost.
i really appreciate all your help, i'll get back as soon as i've revised my code and (knock on wood) got it to work
Again, thanks for all the help!
@hek And that is why I will never be a programmer... I must have looked at that code 4 times! Anyway, thanks! I'll change it tonight when I get home.
Do you think it would be worth updating the example here: http://www.mysensors.org/build/binary to add a child id? I'm wondering if there may be other people out there that may make the same mistake as me.
Thanks again for all you do. I love this stuff!
Great! That worked. I was just trying to get it to work between the node and gateway, and the motion example didn't have the MY_NODE_ID in the example.
Hi! Yes, in node sketch
Example Binary Sketch: (1.5.X and below)
#include <MySensor.h>
#include <SPI.h>
#include <Bounce2.h>
#define CHILD_ID 3
#define BUTTON_PIN 3 // Arduino Digital I/O pin for button/reed switch
MySensor gw;
Bounce debouncer = Bounce();
int oldValue=-1;
// Change to V_LIGHT if you use S_LIGHT in presentation below
MyMessage msg(CHILD_ID,V_TRIPPED);
void setup()
{
gw.begin(NULL, 5);
// Setup the button
pinMode(BUTTON_PIN,INPUT);
// Activate internal pull-up
digitalWrite(BUTTON_PIN,HIGH);
// After setting up the button, setup debouncer
debouncer.attach(BUTTON_PIN);
debouncer.interval(5);
// Register binary input sensor to gw (they will be created as child devices)
// You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage.
// If S_LIGHT is used, remember to update variable type you send in. See "msg" above.
gw.present(CHILD_ID, S_DOOR);
}
// Check if digital input has changed and send in new value
void loop()
{
debouncer.update();
// Get the update value
int value = debouncer.read();
if (value != oldValue) {
// Send in the new value
gw.send(msg.set(value==HIGH ? 1 : 0));
oldValue = value;
}
}
Hi @hek and @scalz
Thanks for your response. I have been unable to locate the guide I thought I previously found... So I probably misread that.
Thank you for the clear answer - which leaves me with only one more ( at the moment )... If I install OpenHAB - will it be able to hand out id's via MQTT? I noticed that the clients without an id keep posting to MQTT... under node id 255...
/th