Closed wired-dev closed 4 years ago
in ZgatewayPilight.ino roughly line 60 in the void pilightCallback(const String &protocol, const String &message, int status, size_t repeats, const String &deviceID) function
replace
void pilightCallback(const String &protocol, const String &message, int status, size_t repeats, const String &deviceID) { if (status == VALID) { trc(F("Creating RF PiLight buffer")); StaticJsonBuffer<JSON_MSG_BUFFER> jsonBuffer; JsonObject& RFPiLightdata = jsonBuffer.createObject(); trc(F("Rcv. Pilight")); RFPiLightdata.set("message", (char *)message.c_str()); RFPiLightdata.set("protocol",(char *)protocol.c_str());
with
void pilightCallback(const String &protocol, const String &message, int status, size_t repeats, const String &deviceID) { if (status == VALID) { trc(F("Creating RF PiLight buffer")); StaticJsonBuffer<JSON_MSG_BUFFER> jsonBuffer; JsonObject& RFPiLightdata = jsonBuffer.createObject(); StaticJsonBuffer<JSON_MSG_BUFFER> jsonBuffer2; JsonObject& msg=jsonBuffer2.parseObject(message); trc(F("Rcv. Pilight")); RFPiLightdata.set("message", (char *)message.c_str()); if(isDigit(msg["id"])){ RFPiLightdata.set("value", msg["id"]); } else { RFPiLightdata.set("value", msg["id"].as<String>()); } RFPiLightdata.set("protocol",(char *)protocol.c_str());
then in the OpenMQTTGateway.ino file I changed it to do strings too. around line 1020 in the void pub(char * topicori, JsonObject& data) function
`void pub(char * topicori, JsonObject& data){
digitalWrite(led_receive, HIGH);
String topic = topicori;
#ifdef valueAsASubject
unsigned long value = data["value"];
if (value != 0){
topic = topic + "/"+ String(value);
}
#endif`
replace with
`void pub(char * topicori, JsonObject& data){
digitalWrite(led_receive, HIGH);
String topic = topicori;
#ifdef valueAsASubject
if(isDigit(data["value"])){
unsigned long value = data["value"];
// if (value != 0){
topic = topic + "/"+ String(value);
} else if(data["value"].as
this makes it work for more devices on pilight.
Where did you add it and how does it help? I own some DG-R8S sensors and use them with HA - could you share your relevant HA config? I tried to use valueAsASubject, but didn't find it useful and currently use demultiplexers.
p.s maybe it's more reasonable to create a PR? ;)
not sure how to do a PR; but yeah just starting with git
went from
home/OMG_PiLight/PilighttoMQTT/message {"id":42,"temperature":23.60,"humidity":43.00,"battery":1,"channel":1} home/OMG_PiLight/PilighttoMQTT/message {"id":"E3","unit":37,"state":"on"}
to
home/OMG_PiLight/PilighttoMQTT/42/message {"id":42,"temperature":23.60,"humidity":43.00,"battery":1,"channel":1} home/OMG_PiLight/PilighttoMQTT/E3/message {"id":"E3","unit":37,"state":"on"}
allowing me to parse my switches and
ha config
sensor:
switch:
I have two omg units one with pilight one without due to some of my devices not working with pilight. also I've found the pilight unit to be flooding the 433mhz band making it hard to work with anything; the normal rf dosn't seem to do this.
I've not tried demultiplexers though. want to post the config on that?
@wired-dev if you need help for the PR don't hesitate to ask questions, in some simple steps:
I resolved the issue for myself by adding ` RFPiLightdata.set("message", (char *)message.c_str());
ifdef valueAsASubject
` to ZgatewayPilight; this also made it easier to read the Digoo-DG-R8S device.