ESPilight support
Support for ESPilight - only recieve at the moment
This commit is contained in:
1 parent
98e2e3b642
commit
b047f5a505
4 files changed
+122
-1
No files matched your search
+17
-1
@@ -61,7 +61,7 @@
|
|||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
|
||||||
// Modules config inclusion
|
// Modules config inclusion
|
||||||
#if defined(ZgatewayRF) || defined(ZgatewayRF2)
|
#if defined(ZgatewayRF) || defined(ZgatewayRF2) || defined(ZgatewayPilight)
|
||||||
#include "config_RF.h"
|
#include "config_RF.h"
|
||||||
#endif
|
#endif
|
||||||
#ifdef ZgatewayRF315
|
#ifdef ZgatewayRF315
|
||||||
@@ -355,6 +355,9 @@ void setup()
|
|||||||
#ifdef ZgatewayRF2
|
#ifdef ZgatewayRF2
|
||||||
setupRF2();
|
setupRF2();
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef ZgatewayPilight
|
||||||
|
setupPilight();
|
||||||
|
#endif
|
||||||
#ifdef ZgatewaySRFB
|
#ifdef ZgatewaySRFB
|
||||||
setupSRFB();
|
setupSRFB();
|
||||||
#endif
|
#endif
|
||||||
@@ -632,6 +635,13 @@ void loop()
|
|||||||
timer_led_receive = millis();
|
timer_led_receive = millis();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef ZgatewayPilight
|
||||||
|
if(PilighttoMQTT()){
|
||||||
|
trc(F("PilighttoMQTT OK"));
|
||||||
|
digitalWrite(led_receive, LOW);
|
||||||
|
timer_led_receive = millis();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#ifdef ZgatewaySRFB
|
#ifdef ZgatewaySRFB
|
||||||
if(SRFBtoMQTT())
|
if(SRFBtoMQTT())
|
||||||
trc(F("SRFBtoMQTT OK"));
|
trc(F("SRFBtoMQTT OK"));
|
||||||
@@ -718,6 +728,9 @@ void stateMeasures(){
|
|||||||
#ifdef ZgatewayRF2
|
#ifdef ZgatewayRF2
|
||||||
modules = modules + ZgatewayRF2;
|
modules = modules + ZgatewayRF2;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef ZgatewayPilight
|
||||||
|
modules = modules + ZgatewayPilight;
|
||||||
|
#endif
|
||||||
#ifdef ZgatewaySRFB
|
#ifdef ZgatewaySRFB
|
||||||
modules = modules + ZgatewaySRFB;
|
modules = modules + ZgatewaySRFB;
|
||||||
#endif
|
#endif
|
||||||
@@ -808,6 +821,9 @@ digitalWrite(led_send, LOW);
|
|||||||
#ifdef ZgatewayRF2
|
#ifdef ZgatewayRF2
|
||||||
MQTTtoRF2(topicOri, datacallback);
|
MQTTtoRF2(topicOri, datacallback);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef ZgatewayPilight
|
||||||
|
MQTTtoPilight(topicOri, datacallback);
|
||||||
|
#endif
|
||||||
#ifdef Zgateway2G
|
#ifdef Zgateway2G
|
||||||
MQTTto2G(topicOri, datacallback);
|
MQTTto2G(topicOri, datacallback);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ const byte subnet[] = { 255, 255, 255, 0 }; //ip adress
|
|||||||
#define ZgatewayIR "IR" //ESP8266, Arduino, Sonoff RF Bridge
|
#define ZgatewayIR "IR" //ESP8266, Arduino, Sonoff RF Bridge
|
||||||
#define ZgatewayBT "BT" //ESP8266, Arduino, ESP32
|
#define ZgatewayBT "BT" //ESP8266, Arduino, ESP32
|
||||||
//#define ZgatewayRF2 "RF2" //ESP8266, Arduino, ESP32
|
//#define ZgatewayRF2 "RF2" //ESP8266, Arduino, ESP32
|
||||||
|
//#define ZgatewayPilight "Pilight" //ESP8266
|
||||||
//#define ZgatewaySRFB "SRFB" // Sonoff RF Bridge
|
//#define ZgatewaySRFB "SRFB" // Sonoff RF Bridge
|
||||||
//#define Zgateway2G "2G" //ESP8266, Arduino, ESP32
|
//#define Zgateway2G "2G" //ESP8266, Arduino, ESP32
|
||||||
//#define ZactuatorONOFF "ONOFF" //ESP8266, Arduino, ESP32, Sonoff RF Bridge
|
//#define ZactuatorONOFF "ONOFF" //ESP8266, Arduino, ESP32, Sonoff RF Bridge
|
||||||
|
|||||||
@@ -0,0 +1,99 @@
|
|||||||
|
/*
|
||||||
|
OpenMQTTGateway - ESP8266 or Arduino program for home automation
|
||||||
|
|
||||||
|
Act as a wifi or ethernet gateway between your 433mhz/infrared IR signal and a MQTT broker
|
||||||
|
Send and receiving command by MQTT
|
||||||
|
|
||||||
|
This gateway enables to:
|
||||||
|
- publish MQTT data to a different topic related to received 433Mhz signal using ESPiLight
|
||||||
|
|
||||||
|
Copyright: (c)Florian ROBERT
|
||||||
|
Copyright: (c)Randy Simons http://randysimons.nl/
|
||||||
|
|
||||||
|
This file is part of OpenMQTTGateway.
|
||||||
|
|
||||||
|
OpenMQTTGateway is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenMQTTGateway is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef ZgatewayPilight
|
||||||
|
|
||||||
|
#include <ESPiLight.h>
|
||||||
|
|
||||||
|
ESPiLight rf(RF_EMITTER_PIN); // use -1 to disable transmitter
|
||||||
|
|
||||||
|
struct Pilightrxd
|
||||||
|
{
|
||||||
|
String protocol;
|
||||||
|
String deviceID;
|
||||||
|
String status;
|
||||||
|
String message;
|
||||||
|
bool hasNewData;
|
||||||
|
};
|
||||||
|
|
||||||
|
Pilightrxd pilightrd;
|
||||||
|
|
||||||
|
void setupPilight(){
|
||||||
|
#ifndef ZgatewayRF && ZgatewayRF2 //receiving with Pilight is not compatible with ZgatewayRF or RF2 as far as I can tell
|
||||||
|
rf.setCallback(pilightCallback);
|
||||||
|
rf.initReceiver(RF_RECEIVER_PIN);
|
||||||
|
trc(F("RF_EMITTER_PIN "));
|
||||||
|
trc(String(RF_EMITTER_PIN));
|
||||||
|
trc(F("RF_RECEIVER_PIN "));
|
||||||
|
trc(String(RF_RECEIVER_PIN));
|
||||||
|
trc(F("ZgatewayPilight setup done "));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean PilighttoMQTT(){
|
||||||
|
rf.loop();
|
||||||
|
|
||||||
|
if(pilightrd.hasNewData){
|
||||||
|
|
||||||
|
pilightrd.hasNewData=false;
|
||||||
|
trc(F("Rcv. Pilight"));
|
||||||
|
String MQTTprotocol;
|
||||||
|
String MQTTdeviceID;
|
||||||
|
String MQTTstatus;
|
||||||
|
String MQTTmessage;
|
||||||
|
|
||||||
|
MQTTprotocol = String(pilightrd.protocol);
|
||||||
|
MQTTdeviceID = String(pilightrd.deviceID);
|
||||||
|
MQTTstatus = String(pilightrd.status);
|
||||||
|
MQTTmessage = String(pilightrd.message);
|
||||||
|
String MQTTPilightstring;
|
||||||
|
MQTTPilightstring = subjectPilighttoMQTT+String("/")+MQTTprotocol+String("/")+MQTTdeviceID;
|
||||||
|
trc(F("Adv data PilighttoMQTT"));
|
||||||
|
client.publish((char *)MQTTPilightstring.c_str(),(char *)MQTTmessage.c_str());
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void pilightCallback(const String &protocol, const String &message, int status,
|
||||||
|
size_t repeats, const String &deviceID) {
|
||||||
|
|
||||||
|
pilightrd.protocol=protocol;
|
||||||
|
pilightrd.deviceID=deviceID;
|
||||||
|
pilightrd.status=status;
|
||||||
|
pilightrd.message=message;
|
||||||
|
pilightrd.hasNewData=true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void MQTTtoPilight(char * topicOri, char * datacallback) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -60,6 +60,11 @@ RF supported protocols
|
|||||||
#define RF2groupKey "GROUP_" // number of your group value will be defined if a subject contains RF2groupKey followed by a value of 1 digit
|
#define RF2groupKey "GROUP_" // number of your group value will be defined if a subject contains RF2groupKey followed by a value of 1 digit
|
||||||
#define RF2dimKey "DIM" // number of your dim value will be defined if a subject contains RF2dimKey and the payload contains the dim value as digits
|
#define RF2dimKey "DIM" // number of your dim value will be defined if a subject contains RF2dimKey and the payload contains the dim value as digits
|
||||||
|
|
||||||
|
/*-------------------ESPPiLight topics & parameters----------------------*/
|
||||||
|
//433Mhz Pilight MQTT Subjects and keys
|
||||||
|
#define subjectMQTTtoPilight Base_Topic Gateway_Name "/commands/MQTTtoPilight"
|
||||||
|
#define subjectPilighttoMQTT Base_Topic Gateway_Name "/PilighttoMQTT"
|
||||||
|
|
||||||
/*-------------------PIN DEFINITIONS----------------------*/
|
/*-------------------PIN DEFINITIONS----------------------*/
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
#define RF_RECEIVER_PIN 0 // D3 on nodemcu
|
#define RF_RECEIVER_PIN 0 // D3 on nodemcu
|
||||||
|
|||||||
Reference in new issue
Block a user