This the code I got so far, which does not work :(
#define MY_RADIO_NRF24 //MySensor Library auf NRF24 Funkmodul einstellen, muss vor MySensor.h Initialisierung geschehen
// Define Node ID
#define MY_NODE_ID 5
//#define MY_PARENT_NODE_ID 50 //Repeater Node 1!
//#define MY_PARENT_NODE_IS_STATIC
#include <MySensors.h>
#include <SPI.h>
#include <IRremote.h>
#define CHILD_ID 1 // Id of the sensor child
IRsend irsend;
// Initialize motion message
MyMessage msg(CHILD_ID, V_IR_SEND);
void setup()
{
Serial.begin(9600);
}
void presentation()
{
// Send the sketch version information to the gateway and Controller
sendSketchInfo("LED Licht TV Steuerung", "1.0");
// Register all sensors to gw (they will be created as child devices)
present(CHILD_ID, S_IR);
}
void loop() {
}
void receive(const MyMessage &message) {
// We only expect one type of message from controller. But we better check anyway.
if (message.type == V_IR_SEND) {
// Send command to Turn LEDs On
if (message.getString() == "FF02FD") { // ???
for (int i = 0; i < 3; i++) {
irsend.sendNEC(0xFF02FD, 32);
Serial.println(message.getString());
Serial.println("Message sent");
delay(40);
}
}
}
}
edit: from the serial monitor I see that the node receives the "FF02FD" String, but it does not enter this part
if (message.getString() == "FF02FD") { // ???
for (int i = 0; i < 3; i++) {
irsend.sendNEC(0xFF02FD, 32);
Serial.println(message.getString());
Serial.println("Message sent");
delay(40);
}
}
edit2:
This is what I am sending from openhab over MQTT:
mygateway1-in/5/1/1/0/32
edit3:
Ok, now I see where it fails:
message.getString()
contains FF02FD
but when I say
if (message.getString() == "FF02FD")
it does not recognise the FF02FD. But I don´t understand why
edit4:
Ok, I got it, finally...:
message.getString("FF02FD");
:astonished: :facepunch: