homieiot / homie-esp8266

💡 ESP8266 framework for Homie, a lightweight MQTT convention for the IoT
http://homieiot.github.io/homie-esp8266
MIT License
1.36k stars 308 forks source link

i try to run example "globalInputHandler" ,but i can't receive message from mqtt broker #407

Closed macyiyin closed 6 years ago

macyiyin commented 7 years ago

this is my code:

include

HomieNode lightNode("light", "switch");

bool globalInputHandler(const HomieNode& node, const String& property, const HomieRange& range, const String& value) { Homie.getLogger() << "Received on node " << node.getId() << ": " << property << " = " << value << endl; return true; }

void setup() { Serial.begin(115200); Serial << endl << endl; Homie_setFirmware("global-input-handler", "1.0.0"); Homie.setGlobalInputHandler(globalInputHandler); lightNode.advertise("on").settable(); Homie.setup(); } void loop() { Homie.loop(); }

this is my config: Hardware device ID: 18fe34e03c37 • Device ID: homietest • Name: callbacktest • Wi-Fi: ◦ SSID: 208 ◦ Password not shown • MQTT: ◦ Host: m2m.eclipse.org ◦ Port: 1883 ◦ Base topic: homie/ ◦ Auth? no

  when it run, i can recieve message from mqtt broker. but i send message "homie/homietest/light" value "on" ,i get nothing from mqtt client. 
  so i try to run mqtt_esp8266_callback.ino from Adafruit MQTT Library , all thing is ok,  i can recieve message. 
  i use homie 2.0 , anyone can help me !
benzino77 commented 7 years ago

Have a look at the Homie convention send on message to homie/homietest/light/set

macyiyin commented 6 years ago

thank you very much