Comments (3)
The example sketch is fine, it was not overwriting the old example when I was copy it over. However, I am still having a problem with the topic. I send homie/relay/light/on/set but it does not get received nor does anything get output to serial or sent from the lightOnHandler.
from convention.
given my node had 2 relays I decided to use the LedStrip sketch as my starting point for my node. This is my final sketch
`#include <Homie.h>
#define FW_NAME "ac_sw_os"
#define FW_VERSION "1.0.0"
/* Magic sequence for Autodetectable Binary Upload */
const char *__FLAGGED_FW_NAME = "\xbf\x84\xe4\x13\x54" FW_NAME "\x93\x44\x6b\xa7\x75";
const char __FLAGGED_FW_VERSION = "\x6a\x3f\x3e\x0e\xe1" FW_VERSION "\xb0\x30\x48\xd4\x1a";
/ End of magic sequence for Autodetectable Binary Upload */
const unsigned char NUMBER_OF_PLUGS = 2;
const unsigned char AC_PINS[NUMBER_OF_PLUGS] = { 12, 14 };
HomieNode plugNode("light", "switch");
bool plugHandler(const HomieRange& range, const String& value) {
plugNode.setProperty("relay").setRange(1).send("test");
Serial << "Range " << range.index << endl;
if (!range.isRange) return false; // if it's not a range
if (range.index < 1 || range.index > NUMBER_OF_PLUGS) return false; // if it's not a valid range
if (value != "on" && value != "off") return false; // if the value is not valid
bool on = (value == "on");
digitalWrite(AC_PINS[range.index - 1], on ? HIGH : LOW);
plugNode.setProperty("relay").setRange(range).send(value); // Update the state of the led
Homie.getLogger() << "Plug " << range.index << " is " << value << endl;
return true;
}
void loopHandler() {
// plugNode.setProperty("relay").setRange(1).send("test");
}
void setup() {
for (int i = 0; i < NUMBER_OF_PLUGS; i++) {
pinMode(AC_PINS[i], OUTPUT);
digitalWrite(AC_PINS[i], LOW);
}
Serial.begin(115200);
Serial << endl << endl;
Homie_setBrand("OutsideRelay"); // before Homie.setup();
Homie_setFirmware(FW_NAME, FW_VERSION);
plugNode.advertiseRange("relay", 1, NUMBER_OF_PLUGS).settable(plugHandler);
Homie.setLoopFunction(loopHandler);
Homie.setup();
}
void loop() {
Homie.loop();
}`
In the loopHandler, when I uncomment the setproperty command, my mosquitto server receives homie/plug/light/relay_1 with a payload of test. The problem is, when I send homie/plug/light/relay_1/set, I get nothing in plugHandler. is that the right topic that I should be sending to?
Thank you,
Mike
from convention.
Hi,
This is the repo of the MQTT convention, not the ESP8266 framework. Anyway, your problem is related to homieiot/homie-esp8266#250 and it was fixed there, can you please pull the latest git? It should fix it. The bug was our fault, you're not doing anything wrong.
from convention.
Related Issues (20)
- $state and $homie can be empty HOT 1
- Human readable types vs machine optimzied types HOT 14
- Please add Java implementation to the list
- Clarify handling of empty strings HOT 13
- add a 'format' for booleans
- Matrix room for project chat HOT 1
- How can I create a settable property, which takes two arguments? HOT 2
- Homie future? HOT 52
- New firmware - GrowNode
- drop the Percent type HOT 1
- add a "step" or "precision" element to the number formats HOT 3
- drop the `node.$type` field
- QoS of non-retained messages HOT 3
- using `set` with retained messages HOT 1
- Define a way to handle NULL values HOT 3
- Protocol Buffer for the payload? HOT 4
- Add location format attribute to Homie V5
- Support streams or binary data HOT 7
- Arrays got removed, but specification uses one as example HOT 10
- Color bug (Homie 5): xyz does not include brightness HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from convention.