Noob--API help?
-
Hi,
Loving this stuff! I'm ready to move on from basics and want to start more original work. Hence the need to dive into the API.
Is there any guide, beyond the description on the API page as to how it all fits together?
For example I'm trying to run my loop() code based on the state of the device in Vera. The hardware and program runs OK, and the node is talking to the GW. I'd really benefit from some kind of tutorial. Is there such a thing? I don't seem to grasp it all yet.
Thanks in advance,
--Steve
-
I solved my immediate concern by gleening off other sketches. It's another way to learn. Now I can control my loop by checking the state on the controller.
Learning a little along the way. My question remains--is there a resource available beyond the API page that outlines the steps to embrace this awesome technology?
Thanks,
--Steve
-
@SteveO1234 said:
I don't seem to grasp it all yet.
building off of @SteveO1234 's good advice, well you can always ask directed questions here.
@SteveO1234 said:
I'm trying to run my loop() code based on the state of the device in Vera.
try posting your code (between three back-ticks (accent like character below the tilde(~) character on my mac)
typing this:
looks like this:
myCode is here in this box
when posted.
-
Thanks for the encouragement and help! So it seems as I need to create this message handler function that is referenced in the gw.begin().. And from that point any incoming messages are routed through the function?
// void incomingMessage(const MyMessage &message) { if (message.isAck()) { Serial.println("This is an ack from gateway"); } if (message.type == V_LIGHT) { // Change relay state state = message.getBool(); Serial.print ("State = "); Serial.print (state); // Store state in eeprom gw.saveState(ID, state); Serial.print("Incoming change for sensor:"); Serial.print(message.sensor); Serial.print(", New status: "); Serial.println(message.getBool()); } } //
-
Correct.
-
@SteveO1234 said:
Thanks for the encouragement and help! So it seems as I need to create this message handler function that is referenced in the gw.begin().. And from that point any incoming messages are routed through the function?
yup,
So, you then have to manage a variable Vera-side that will then get polled from time to time by your Arduino. that request is bounced back as a message, that you handle as you noted above.
Look at this example to see how you can manage the change of a stored variable in the Vera device... you merely need to update the stored variable in a change of state, and poll as frequently as you want to update.
You can also send Vera html messages that in-turn would generate a message to a node in MySensors space.
have fun!
Suggested Topics
-
Arduino Celebrates 10 years (Malmö/Sweden)
Announcements • 29 Mar 2014, 17:08 • hek 29 Mar 2014, 17:08 -
MQTT-Help me understand about the MQTT Gateway.
Development • 2 Mar 2025, 01:44 • dpcons 12 Mar 2025, 23:39 -
LAN8720A - will mysensors work with this module
Development • 13 Nov 2024, 17:06 • Marcin 15 Nov 2024, 10:59 -
Saving last known good state, but not in EEPROM
Development • 30 Jan 2024, 18:46 • OldSurferDude 15 Jan 2025, 08:51 -
Home Assistant/MySensors quirks
Development • 17 Mar 2025, 02:35 • OldSurferDude 17 Mar 2025, 02:35 -
Sending offset to node
Development • 31 Jan 2025, 00:59 • bsl88k 4 Feb 2025, 12:14