Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When may setNodeProperty() be invoked? #40

Closed
jpmens opened this issue Mar 20, 2016 · 7 comments
Closed

When may setNodeProperty() be invoked? #40

jpmens opened this issue Mar 20, 2016 · 7 comments

Comments

@jpmens
Copy link

jpmens commented Mar 20, 2016

First of all, thank you for building Homie-ESP8266; this is grand.

Assuming I want to add a property to a node to indicate the unit, I tried doing

Homie.setNodeProperty(tempnode, "unit", "C", true);

in setup(), just before registerNode(), just after, and after Homie.setup(), none of which works. The only place I seem to succeed in seeing this property is if I add it to a loop handler, which is a shame, as it's a one-time only constant property.

Am I holding it incorrectly? :-)

@marvinroger
Copy link
Member

Thanks a lot. :)

Perfect timing, I've just updated the temperature example with what you want! What you need is setSetupFunction().

To answer to your question, the setNodeProperty() function can be invoked when the device is in normal mode and connected to both the Wi-Fi and MQTT broker. The setupFunction and loopFunction that you can register are called when this condition is true.

@jpmens
Copy link
Author

jpmens commented Mar 20, 2016

I've built and uploaded your temperature example, but I don't get a unit:

devices/0d87bde0/$nodes temperature:temperature
devices/0d87bde0/$online true
devices/0d87bde0/$name Bookshelf
devices/0d87bde0/$localip 192.168.1.192
devices/0d87bde0/$fwname awesome-temperature
devices/0d87bde0/$fwversion 1.0.0
devices/0d87bde0/$signal 92
devices/0d87bde0/temperature/temperature 22.00

In the Arduino IDE's serial monitor I see

Attempting to connect to Wi-Fi
Attempting to connect to MQTT
Sending initial informations
Sending Wi-Fi signal quality
Temperature: 22.00 C

@marvinroger
Copy link
Member

Oh, you're right. Let me take a look at it.

@jpmens
Copy link
Author

jpmens commented Mar 20, 2016

I think it's the same issue I had earlier: a Serial.print() in setupHandler indicates it's being called before the MQTT connection is up.

@marvinroger
Copy link
Member

Could you please try again with the latest git rev?

@jpmens
Copy link
Author

jpmens commented Mar 20, 2016

Works like a charm:

devices/0d87bde0/temperature/unit c
devices/0d87bde0/temperature/aaaaaaa AAAA

Thank you for fixing this so quickly.

@jpmens jpmens closed this as completed Mar 20, 2016
@marvinroger
Copy link
Member

Great, my pleasure!

@marvinroger marvinroger added this to the 1.2.0 milestone Mar 20, 2016
gorec2005 pushed a commit to gorec2005/homie-esp8266 that referenced this issue Jun 28, 2020
tested with chromium and firefox and all content types i had handy.

chrome and firefox render all files inline, if they can. chrome downloads files when asked to download, firefox opens a download dialog.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants