rc-switch plugin
Moderators: grovkillen, Stuntteam, TD-er
Re: rc-switch plugin
Can someone post my plugins to the Github Plugin playground?: https://github.com/letscontrolit/ESPEas ... Playground
No clue how to do this... Maybe this way the plugins will find their way to the final builds.
By the way, i also use these modules now: https://www.aliexpress.com/item/433-Mhz ... 52611.html they work fine and are nice and small.
No clue how to do this... Maybe this way the plugins will find their way to the final builds.
By the way, i also use these modules now: https://www.aliexpress.com/item/433-Mhz ... 52611.html they work fine and are nice and small.
Re: rc-switch plugin
Hi s4nder,
Thanks for yur plugin!
I am using it and it workrks great!
Also I am using modules from exactly same seller - they working fine.
Thanks for yur plugin!
I am using it and it workrks great!
Also I am using modules from exactly same seller - they working fine.
Re: rc-switch plugin
For my understanding, under 'commando' it expects the raw binary sequence? Higher level command from rc-switch (like the ones mentioned here) are not supported, right?
Re: rc-switch plugin
It uses a 8 digit code that is received with the reciever plugin. Then you can use it like this:oisisi wrote:For my understanding, under 'commando' it expects the raw binary sequence? Higher level command from rc-switch (like the ones mentioned here) are not supported, right?
http://*yourwemos*/control?cmd=RFSEND,10939202,2
Where '10939202' should be the code u see in the esp-easy logging, from the reciever plugin. The plugins i made do not have support for tri-state (.sendTriState) or other commands (.switchOn) yet, it uses only .send(). But in most cases for me, the 8 digit codes do somehow work here...
Re: rc-switch plugin
Thanks for the reply. I now hacked together my own standalone sketch. Regrettably, I lack the skills to work it into a plugin.
Re: rc-switch plugin
Post it here, we might try to create a plugin out of it...
Re: rc-switch plugin
I was afraid this would pop up. It is currently very ugly, I'll clean it up a bit and post it.data wrote:Post it here, we might try to create a plugin out of it...
Re: rc-switch plugin
Well you were warned. Here it is. It works with sockets that have dip switches for selecting the code and ones with two rotary code selectors.data wrote:Post it here, we might try to create a plugin out of it...
Code: Select all
/*
MQTT -> ESP8266 -> RC controlled socket
parsing JSON formatted topic and turns 433.92 MHz
radio controlled sockets on or off using library RCSwitch
two protocols are defined:
prot 1 uses two five-digit binary codes
prot 2 uses two int values
The topic of choice is "home/action/rfbridge"
Command line examples as published using mosquitto:
mosquitto_pub -t home/action/rfbridge -m "{prot: 1, state: 1, ident: 10000, unit: 10000}"
mosquitto_pub -t home/action/rfbridge -m "{prot: 2, state: 1, ident: 2, unit: 4}"
The JSON library isn't to picky about properly formatted objects. From Node_RED I would send
as payload {"prot": 2, "state": 1, "ident": 2, "unit": 4}
-- oisisi
*/
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include <RCSwitch.h>
#include <ArduinoJson.h>
// #define DEBUG
const char* ssid = "....";
const char* password = "....";
const char* mqtt_server = "....";
WiFiClient espClient;
PubSubClient client(espClient);
RCSwitch mySwitch = RCSwitch();
void setup() {
Serial.begin(115200);
setup_wifi();
client.setServer(mqtt_server, 1883);
client.setCallback(callback);
// sender's data in pin is connected to WEMOS pin D6
mySwitch.enableTransmit(D6);
}
void setup_wifi() {
delay(10);
// We start by connecting to a WiFi network
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
// MQTT message received callback
void callback(char* topic, byte* payload, unsigned int length) {
// prep JSON buffer
StaticJsonBuffer<90> jsonBuffer;
Serial.print("Message arrived [");
Serial.print(topic);
Serial.print("] ");
Serial.println("");
Serial.println("length: " + String(length));
for (int i = 0; i < length; i++) {
Serial.print((char)payload[i]);
}
Serial.println();
// copy MQTT payload into JSON object
JsonObject& root = jsonBuffer.parseObject(payload);
if (!root.success()) {
Serial.println("parseObject() failed");
return;
}
// JSON values -> vars
// state 1 is on, 0 is off
int swstate = root["state"];
// store protocol
int swprot = root["prot"];
// reject if protocol declaration is missing/wrong
if (swprot != 2 && swprot != 1) {
Serial.print(swprot);
Serial.println(" no protocol defined");
return;
}
// if switch should be turned on
if ( swstate == 1 ) {
// if protocol is of type 2
if ( swprot == 2) {
// store values as INTs
int swunit = root["unit"];
int swident = root["ident"];
// pass values to RCSwitch
mySwitch.switchOn(swunit, swident);
}
// if protocol is of type 1
if ( swprot == 1) {
// store values as const char*
const char* swunit = root["unit"];
const char* swident = root["ident"];
// pass values to RCSwitch
mySwitch.switchOn(swunit, swident);
}
// everything below this is redundant or debug stuff
// if switch should be turned off
} else {
if ( swprot == 2) {
int swunit = root["unit"];
int swident = root["ident"];
mySwitch.switchOff(swunit, swident);
}
if ( swprot == 1) {
const char* swunit = root["unit"];
const char* swident = root["ident"];
mySwitch.switchOff(swunit, swident);
}
}
}
void reconnect() {
// Loop until we're reconnected
while (!client.connected()) {
Serial.print("Attempting MQTT connection...");
// Attempt to connect
if (client.connect("ESP8266Client")) {
Serial.println("connected");
// this is the topic we're listening to
client.subscribe("home/action/rfbridge");
} else {
Serial.print("failed, rc=");
Serial.print(client.state());
Serial.println(" try again in 5 seconds");
// Wait 5 seconds before retrying
delay(5000);
}
}
}
void loop() {
if (!client.connected()) {
reconnect();
}
client.loop();
yield();
}
Re: rc-switch plugin
Ill try to see if I can get any logic in the plugin to support dip switches. But for now, my time is limited.
Does anyone know how to publish scripts to the Github repository (or playground or wherever)? I always get this message when syncing: 'Sync failed to push local changes, it seems you do not have permission to push your changes to this repository'...
Any developers here willing to share some knowledge on this?
Re: rc-switch plugin
I'm not very versed with github but generally you fork into your own repo online, submit your commit(s) to that and then file a pull request against the original repo.
Re: rc-switch plugin
Hi s4nder,
Thx for code, it works well for me.
I've made a pull request on ESPEasyPluginPlayground to integrate your plugins.
Thx for code, it works well for me.
I've made a pull request on ESPEasyPluginPlayground to integrate your plugins.
Re: rc-switch plugin
Plugins are now available @ https://github.com/letscontrolit/ESPEas ... Playground
Re: rc-switch plugin
Strange, I tried to upload them a few days ago and the files where there for a few hours. Now i still can't find them. Why are they removed?
Re: rc-switch plugin
s4nder,
First of all thanks for your RF Tx/Rx plugins - works great!
Can you add to your Plugin 111: Input RF option to receive data from Livolo switches based on this arduino scetch?
I am using OpenHab and many of rc-switch compatible devices plus Livolo switches in my house, so it will be very convinient to control them.
As of today I am using arduino connected to serial port of ESP for this purpose.
I think that many other ESPEasy users will be happy to use this option.
Thanks in advance,
Igor
First of all thanks for your RF Tx/Rx plugins - works great!
Can you add to your Plugin 111: Input RF option to receive data from Livolo switches based on this arduino scetch?
I am using OpenHab and many of rc-switch compatible devices plus Livolo switches in my house, so it will be very convinient to control them.
As of today I am using arduino connected to serial port of ESP for this purpose.
I think that many other ESPEasy users will be happy to use this option.
Thanks in advance,
Igor
Re: rc-switch plugin
When I try to compile u plugin i have error:
on this line:
Code: Select all
'irReceiver' was not declared in this scope
Code: Select all
if (irReceiver != 0) break;
Re: rc-switch plugin
@ipua; I think it would be better if someone would create a new plugin for that. This plugin only supports the RC-switch library.
@annakin; Also use the _P035_IRTX.ino and _P016_IR.ino plugins, then it will work.
I tried to make a newer version that can control Tristate/ Dip Switch/ Intertechno swithes. But, I do not have any hardware to test this, so can someone test this for me?
You can view the latest plugins on my github page: https://github.com/sanderpleijers/EspEasy-RC-Switch
@annakin; Also use the _P035_IRTX.ino and _P016_IR.ino plugins, then it will work.
I tried to make a newer version that can control Tristate/ Dip Switch/ Intertechno swithes. But, I do not have any hardware to test this, so can someone test this for me?
You can view the latest plugins on my github page: https://github.com/sanderpleijers/EspEasy-RC-Switch
Re: rc-switch plugin
We also have another rcswitch plugin on the playground? anyone knows whats going on with that?
https://github.com/letscontrolit/ESPEas ... -Switch-TX
https://github.com/letscontrolit/ESPEas ... -Switch-TX
Re: rc-switch plugin
@psy0rz; verry good question, I did not see that until now! It is not of my making... Code looks a wee bit shorter that what I stamped together...
I cannot say that my version is better or not, I barely have time to code everything... Ill leave that to you pro-coders
I cannot say that my version is better or not, I barely have time to code everything... Ill leave that to you pro-coders
Re: rc-switch plugin
Hi s4nder!
Thank you for your plugin.
Unfortunately, ESPEasy crashes with it. I think it is rcswitch issues. I use version 2.52.
Could you send me link for library you use?
Thank you for your plugin.
Unfortunately, ESPEasy crashes with it. I think it is rcswitch issues. I use version 2.52.
Could you send me link for library you use?
Re: rc-switch plugin
I use this RC-Switch plugin from playground to send RF commands to my DIP-coded RF power outlets, works great!
https://github.com/letscontrolit/ESPEas ... -Switch-TX
it can send
https://github.com/letscontrolit/ESPEas ... -Switch-TX
it can send
- binary code with any length ("RC,SEND=000000000001010100010001")
- tristate code with any length ("RC,SEND=00000FFF0F0F")
- 24 bit decimal code ("RC,SENDDEC=5393")
- binary code for simple 10 DIP switch devices ("RC,ON=1010100010")
- switch position for simple 2 rotary switch devices ("RC,ON=42")
- switch position for Intertechno devices ("RC,ON=a42")
Re: rc-switch plugin
@Mics78; I used rc-switch 2.6.2 (straight from github) together with the ESP-easy mega dev8 release. That works for me...
@trs: Your code looks great, my own code is kinda messy with conversions/variables but for me it works. What I really use from my own code is that I can save the pulselength or repeats in the settings so you don't have to worry about that anymore.
It seems to me that lots of people want this functionality in ESP-Easy, can we somehow kindly inform the developers to include these plug-ins in upcoming ESP easy (mega?) releases?
@trs: Your code looks great, my own code is kinda messy with conversions/variables but for me it works. What I really use from my own code is that I can save the pulselength or repeats in the settings so you don't have to worry about that anymore.
It seems to me that lots of people want this functionality in ESP-Easy, can we somehow kindly inform the developers to include these plug-ins in upcoming ESP easy (mega?) releases?
Re: rc-switch plugin
+1s4nder wrote: ↑16 May 2017, 15:10 @Mics78; I used rc-switch 2.6.2 (straight from github) together with the ESP-easy mega dev8 release. That works for me...
@trs: Your code looks great, my own code is kinda messy with conversions/variables but for me it works. What I really use from my own code is that I can save the pulselength or repeats in the settings so you don't have to worry about that anymore.
It seems to me that lots of people want this functionality in ESP-Easy, can we somehow kindly inform the developers to include these plug-ins in upcoming ESP easy (mega?) releases?
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8
Re: rc-switch plugin
Thank you.
I try to use rc-switch 2.6.2 with Arduino IDE 1.8.1 and 1.8.2 and receive an compilation's error:
C:/users/michael/appdata/local/arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: C:\Users\Michael\AppData\Local\Temp\arduino_build_252850/ESPEasy.ino.elf section `.text' will not fit in region `iram1_0_seg'
collect2.exe: error: ld returned 1 exit status
If I return 2.5.2 version I have no error compilation but I have reboots my device...
I need receiver functionality in ESPEasy...
I try to use rc-switch 2.6.2 with Arduino IDE 1.8.1 and 1.8.2 and receive an compilation's error:
C:/users/michael/appdata/local/arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: C:\Users\Michael\AppData\Local\Temp\arduino_build_252850/ESPEasy.ino.elf section `.text' will not fit in region `iram1_0_seg'
collect2.exe: error: ld returned 1 exit status
If I return 2.5.2 version I have no error compilation but I have reboots my device...
I need receiver functionality in ESPEasy...
Re: rc-switch plugin
@Mics78; remove some un-needed plugins from the ESP-Easy source. The error you get means that the firmware is too big...
Re: rc-switch plugin
Hello All,
I've a question. Can i use this plugin for a stand alone version of Vhome Smart Home RF433MHZ Switch Shape Smart Remote Control in combination with ESP Easy, RfxCom and Domoticz?
Or did i need extra hardware for this unit?
https://nl.aliexpress.com/item/Vhome-Sm ... Title=true
I've a question. Can i use this plugin for a stand alone version of Vhome Smart Home RF433MHZ Switch Shape Smart Remote Control in combination with ESP Easy, RfxCom and Domoticz?
Or did i need extra hardware for this unit?
https://nl.aliexpress.com/item/Vhome-Sm ... Title=true
Re: rc-switch plugin
I am now using "Plugin 144: RC-Switch TX" from the plugin playground together with the current Mega release. It works nicely with my dip switch and rotary type sockets. Regrettably, I can't get it to work with MQTT so I have to to issue get requests (e.g. http://192.168.4.151/control?cmd=RC,ON=1000010000,5).
If anyone knows the proper topic and syntax to publish the command I would be even more happy. I've tried all thinkable variations of topics and payloads (e.g. 'mosquitto_pub -t "home/esp014/cmd" -m "RC,ON=1000010000,5"' while the module is subscribed to "home/esp/#") but nothing happens.
If anyone knows the proper topic and syntax to publish the command I would be even more happy. I've tried all thinkable variations of topics and payloads (e.g. 'mosquitto_pub -t "home/esp014/cmd" -m "RC,ON=1000010000,5"' while the module is subscribed to "home/esp/#") but nothing happens.
Re: rc-switch plugin
I am using openhab and items file contains:
In your case - try 'mosquitto_pub -t "home/esp014/cmd" -m "rfsend,1000010000,5"
Hope this helps..
Code: Select all
mqtt=">[broker:/ESP1/cmd:command:on:rfsend,1111111],>[broker:/ESP1/cmd:command:off:rfsend,22222222]
In your case - try 'mosquitto_pub -t "home/esp014/cmd" -m "rfsend,1000010000,5"
Hope this helps..
Re: rc-switch plugin
Regrettably this and variants thereof don't work. My device is named "rcswitch" so I tried `mosquitto_pub -t "home/esp014/cmd" -m "rcswitch,ON=1000010000,5"` - no dice. I think a command beginning with 'rc' is expected:
Code: Select all
case PLUGIN_WRITE:
{
String command = parseString(string, 1);
if (command == F("rc"))
{
String param;
byte paramIdx = 2;
string.replace(" ", " ");
string.replace(" =", "=");
string.replace("= ", "=");
Re: rc-switch plugin
All command names are independent of the task names. To trigger the RCswitch you have to use the command "RC".
-> "RC,ON=1000010000,5" should work
Note: commands are only be executed on enabled tasks.
-> "RC,ON=1000010000,5" should work
Note: commands are only be executed on enabled tasks.
Re: rc-switch plugin
Thanks for the advice. Regrettably it doesn't work. I can see that the payload arrives in the log:
Code: Select all
mosquitto_pub -t "home/esp014/cmd" -m "RC,ON=1000010000,5"
Code: Select all
375247309 : MQTT : Topic: home/esp014/cmd
375247309 : MQTT : Payload: RC,ON=1000010000,5
While the get request
Code: Select all
wget -qO- "http://192.168.178.151/control?cmd=RC,ON=1000010000,5"
Code: Select all
375429728 : on=1000010000
375429728 : ON
375429728 : 1000010000
375430269 : 5
Re: rc-switch plugin
The _P111_RF.ino plugin do not compile in dev10 https://github.com/letscontrolit/ESPEasy/releases.
In dev7 version the plugin compiles
I need the dev10 version
Please help
Thanks
Code: Select all
'irReceiver' was not declared in this scope
if (irReceiver != 0) break;
I need the dev10 version
Please help
It is working now.Also use the _P035_IRTX.ino and _P016_IR.ino plugins, then it will work.
Thanks
Re: rc-switch plugin
Is your first controller "OpenHAB MQTT" ???oisisi wrote: ↑13 Jun 2017, 17:57Code: Select all
375247309 : MQTT : Topic: home/esp014/cmd 375247309 : MQTT : Payload: RC,ON=1000010000,5
Re: rc-switch plugin
That's the problem!
The log you see comes from controller.ino which is common for all controllers.
The syntax descriped above is only implemented in "OpenHAB MQTT" (CPlugin 5).
In "PiDome MQTT" (CPlugin 6) it is implementet differently - as I understand the code you must use "/Home/Floor/Location/device/<systemname>/RC,ON=1000010000,5" (<sysname> must be the 5th element!!!) - don't ask me why...
You/I/any should request a common MQTT-command handling independent of the active plugin
Last edited by JKD on 21 Jun 2017, 16:12, edited 1 time in total.
Re: rc-switch plugin
Thanks for tenaciously investigating the cause. Since I use plain MQTT / Node RED and not really a specific controller I can find a workaround.
Re: rc-switch plugin
i try to compile dev11 with Arduino IDE 1.6.12 as suggested here: https://www.letscontrolit.com/wiki/inde ... are_Upload
Compiling is possible for dev11 without any plugins from the playground.
When I add _P111_RF.ino and _P112_RFTX.ino or only one of them I get exit status 1.
any suggestions? It would be nice if someone can upload a already compile dev11.bin for Nodemcu board.
Hope somebody can help
Compiling is possible for dev11 without any plugins from the playground.
When I add _P111_RF.ino and _P112_RFTX.ino or only one of them I get exit status 1.
any suggestions? It would be nice if someone can upload a already compile dev11.bin for Nodemcu board.
Hope somebody can help
Re: rc-switch plugin
I used the latest files with the most recent Arduino IDE, took out a few plugins that added too much to the size, I added the two mentioned plugins and it compiled with only one warning. Try fetching the latest Arduino IDE.
Re: rc-switch plugin
ok...i will try it this afternoon.
Can U upload your compiled .bin?
Can U upload your compiled .bin?
Re: rc-switch plugin
I tried compiling the latest github ESPEasy mega source with Arduino IDE 1.8.3 and can compile ESPEasy (dev11).
When I copy _P144_RC-Switch-TX.ino from the playground it works for me, too. Same for _P112_RFTX.ino.
But when I add _P111_RF.ino i get the following error message:
exit status 1
'irReceiver' was not declared in this scope
I also considered the suggestion "Also use the _P035_IRTX.ino and _P016_IR.ino plugins, then it will work." mentioned in the post of kniazio.
Any Idea
When I copy _P144_RC-Switch-TX.ino from the playground it works for me, too. Same for _P112_RFTX.ino.
But when I add _P111_RF.ino i get the following error message:
exit status 1
'irReceiver' was not declared in this scope
I also considered the suggestion "Also use the _P035_IRTX.ino and _P016_IR.ino plugins, then it will work." mentioned in the post of kniazio.
Any Idea
Re: rc-switch plugin
ok. I fixed it myself. As mentioned above (by by oisisi in post #57), I had to delete many standard plugins (more than 5 depends on the size) to get It compiled. It´s also necessary to get a really clean portable version of Arduino IDE with the necessary libraries. Very important to do exactly what is described in the tutorial.
Re: rc-switch plugin
Hi.
First, thanks a lot to the developer(s) for the rc-switch plugin. I have used it for more than a year with my RC sockets in combination with MQTT and Openhab and found it very stable.
However, for some reason, my commands are always repeated 3 times it seems. Despite the device setup is made with repeat=1 and the mqtt payload is always with 1
example: mymosquitto:/IOT_MASTER/cmd:command:Up:rfsend,16059141,1,24
For the control of RF sockets it does not matter to repeat a few times or more. However, in setting up LED light control with some min RF controllers, and when toggling light on/off, repeating the command is making the light blinkering and leaving the controller in and unkown state, which makes it difficult.
I have not gone trough the code in details for some easy parameters adjustments, i wanted to hear if i'm the only one having theese issues?
I found about about the minimum 3 repeats by recieving the RC signals with the original RC-switch code for arduino "RecieveDemo_Advanced":
First, thanks a lot to the developer(s) for the rc-switch plugin. I have used it for more than a year with my RC sockets in combination with MQTT and Openhab and found it very stable.
However, for some reason, my commands are always repeated 3 times it seems. Despite the device setup is made with repeat=1 and the mqtt payload is always with 1
example: mymosquitto:/IOT_MASTER/cmd:command:Up:rfsend,16059141,1,24
For the control of RF sockets it does not matter to repeat a few times or more. However, in setting up LED light control with some min RF controllers, and when toggling light on/off, repeating the command is making the light blinkering and leaving the controller in and unkown state, which makes it difficult.
I have not gone trough the code in details for some easy parameters adjustments, i wanted to hear if i'm the only one having theese issues?
I found about about the minimum 3 repeats by recieving the RC signals with the original RC-switch code for arduino "RecieveDemo_Advanced":
Code: Select all
/*
Example for receiving
http://code.google.com/p/rc-switch/
If you want to visualize a telegram copy the raw data and
paste it into http://test.sui.li/oszi/
*/
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
void setup() {
Serial.begin(9600);
mySwitch.enableReceive(0); // Receiver on inerrupt 0 => that is pin #2
}
void loop() {
if (mySwitch.available()) {
output(mySwitch.getReceivedValue(), mySwitch.getReceivedBitlength(), mySwitch.getReceivedDelay(), mySwitch.getReceivedRawdata(),mySwitch.getReceivedProtocol());
mySwitch.resetAvailable();
}
}
Re: rc-switch plugin
I have also issues compiling with the _P111_RF.ino included. I tried reinstaling the IDE + removed the libraries folder and only included the ones from the ESP Easy distribution.
Still the same, any other ideas?
Still the same, any other ideas?
Re: rc-switch plugin
Old thread, but... Apply this patch to the head of _P111 enables it to compile:sebi2003 wrote: ↑11 Aug 2017, 19:24 But when I add _P111_RF.ino i get the following error message:
exit status 1
'irReceiver' was not declared in this scope
I also considered the suggestion "Also use the _P035_IRTX.ino and _P016_IR.ino plugins, then it will work." mentioned in the post of kniazio.
Any Idea
Code: Select all
#ifndef USES_P016
int irReceiver = 0; // make sure it has value even if plugin not found
#endif
Who is online
Users browsing this forum: No registered users and 36 guests