Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update rc-switch #313

Merged
merged 1 commit into from Nov 15, 2018

Conversation

Projects
None yet
4 participants
@animavitis
Copy link
Contributor

commented Nov 15, 2018

@1technophile
As the RF gateway is the most used gateway of OMG how do you think we can assure other users this change will not generate regressions on their side?

@animavitis
To be honest we cant assure.
ive tested this repo with my esp32 & esp8266 devices and it works fine & stable (tested only with RF).
Other things we can do is:

  • static code analysis (Im not good enough developer , so it looks like it will be your job :) )
  • deploy changes as next beta version and ask users for feedback.
@1technophile

This comment has been minimized.

Copy link
Owner

commented Nov 15, 2018

let's try it before the release!

@1technophile 1technophile added this to the V0.9 milestone Nov 15, 2018

@1technophile 1technophile merged commit 5d01071 into 1technophile:master Nov 15, 2018

1 check was pending

continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
@@ -695,7 +831,118 @@ void RECEIVE_ATTR RCSwitch::handleInterrupt() {
repeatCount = 0;
}

RCSwitch::timings[changeCount++] = duration;
// заносим в массив длительность очередного принятого импульса
if (changeCount > 0 & duration < 100) { // игнорируем шумовые всплески менее 100 мкс

This comment has been minimized.

Copy link
@johnou

johnou Dec 17, 2018

Contributor

@animavitis shouldn't this be if (changeCount > 0 && duration < 100) {

This comment has been minimized.

Copy link
@animavitis

animavitis Dec 17, 2018

Author Contributor

It looks like it should :)
thanks for catching this

This comment has been minimized.

Copy link
@johnou

johnou Dec 17, 2018

Contributor

👍 #330

This comment has been minimized.

Copy link
@johnou

johnou Dec 17, 2018

Contributor

@animavitis if I wanted to add support for Cardin, how would I go about it given the new format of the protocols? Unfortunately I do not understand the Russian comments. I took a dump of the remote using Audacity.

cardin.zip

This comment has been minimized.

Copy link
@animavitis

animavitis Dec 17, 2018

Author Contributor

I switched to this version of rc-switch cause it have a lot more protocols and it works out of the box with my devices :)

To find new protocol u can use this: https://github.com/OperKH/rc-switch/tree/master/examples/ReceiveDemo_Advanced

Just open it in arduino, build & deploy, then open serial console and check if your protocol or RAW code is logged.

This comment has been minimized.

Copy link
@johnou

johnou Dec 18, 2018

Contributor

@Martin-Laclaustra I'm having trouble interpreting the results, could I trouble you for your expertise? I noticed you have a few branches which seem promising ie. sending raw timing values.

This comment has been minimized.

Copy link
@johnou

johnou Dec 18, 2018

Contributor

@Martin-Laclaustra I also tried your transmittimingsarray branch to send the raw values but that didn't work so I'm at a bit of a loss..

This comment has been minimized.

Copy link
@Martin-Laclaustra

Martin-Laclaustra Dec 18, 2018

Sorry, I do not have plenty of time. I skimmed the code and tried to understand what is this all about (I inferred: accommodating long codes and double sync bits). Russian comments do not help. I will just comment about code correctness: "&&" (logical operator) seems what has to be used in that line instead of "&" (bitwise operator). I cannot tell anything about the function of the whole code.

This comment has been minimized.

Copy link
@johnou

johnou Dec 18, 2018

Contributor

@Martin-Laclaustra thanks for the reply, tagging you in a comment of this pull request was perhaps not the best place. I am essentially trying to duplicate my Cardin gate remote transmission so I can automate it, I have created a circuit to record 433mhz to my pc with Audacity which was a success but I had trouble with the freq and timings, I then found https://github.com/sui77/SimpleRcScanner and your transmittimingsarray branch which seemed promising, I took the average of the raw values high and low then passed them into the send method but no dice, I was hoping to work out the protocol to add it directly into RCSwitch.cpp but I am having trouble understanding some rf lingo and working out the correct values based on the capture. I am attaching it here in the hope you might have a few spare minutes to check it out.

button1_capture1

button 1

789,822,388,430,792,432,774,441,776,830,390,419,798,425,787,429,782,818,399,823,391,813,407,811,404,806,409,811,399,428,782,824,396,821,391,820,387,432,790,822,394,820,397,817,391,823,403,807,400,816,397,431,786,815,403,813,410,800,404,423,9801,8160,195,489,331,471,349,442,373,425,392,416,390,430,381,426,395,406,394,419,395,428,4020,452,766,442,787,429,788,424,784,817,406,424,781,825,399,427,785,429,784,810,410,804,406,427,788,430,785,822,397,425,781,429,791,423,786,820,403,424,789,818,402,414,796,815,389,821,406,817,400,418,792,425,788,427,783,427,791,428,785,430,779,431,788,428,793,817,394,421,790,434,783,428,789,820,395,427,784,442,775,424,795,813,397,436,773,438,780,431,783,832,384,823,397,812,400,817,400,810,406,808,400,422,795,826,391,812,407,804,403,428,792,810,403,814,398,816,401,811,400,823,393,815,399,421,798,804,412,819,394,807,406,426,10684,7256,205,500,321,476,348,440,363,442,375,431,385,432,378,420,389,423,392,420,386,418,4039,448,770,434,785,436,780,426,782,828,399,424,780,829,389,427,806,400,797,821,397,818,399,421,790,431,783,817,398,424,785,431,790,424,791,824,391,428,784,824,390,424,794,817,395,824,390,819,395,427,788,427,788,426,788,433,783,428,782,429,789,427,792,430,777,826,389,432,786,432,777,440,776,824,399,424,783,426,789,435,792,807,402,424,783,434,789,431,778,819,398,816,397,815,402,815,397,818,403,810,400,427,784,825,388,823,402,809,400,428,785,816,406,811,402,807,409,816,397,812,405,810,399,430,789,812,396,813,413,804,401,423,10870,7103,182,511,312,458,357,444,374,424,389,423,389,415,390,424,389,422,387,424,385,428,4024,448,780,429,787,430,782,430,786,825,389,429,783,828,395,419,792,430,774,826,399,819,399,420,785,425,789,829,385,440,774,437,783,426,783,821,394,438,770,822,403,433,783,815,401,811,406,816,397,428,779,438,779,426,785,429,788,431,789,427,774,446,783,425,785,819,388,441,784,422,796,421,784,828,382,435,791,428,781,434,784,814,401,427,790,427,787,428,780,823,389,826,386,827,394,823,393,820,395,819,397,414,798,816,400,815,399,812,406,415,

392,815,408,418,796,813,401,813,396,816,406,808,407,814,398,815,393,433,781,822,402,808,409,808,405,417,14731,2367,247,521,298,473,345,457,361,438,378,432,378,424,385,430,384,420,389,425,384,425,385,425,4031,829,392,822,401,424,786,818,396,433,785,822,393,430,785,427,788,429,789,819,396,815,395,429,783,436,782,429,784,820,397,824,391,820,392,821,402,421,791,423,790,818,394,822,393,426,793,813,401,426,785,818,400,422,791,817,397,817,394,423,795,818,398,421,792,817,399,425,786,429,790,426,786,814,400,428,789,424,794,418,792,814,402,429,783,421,794,431,779,824,397,816,403,818,391,822,394,814,399,820,401,422,792,810,405,815,393,817,397,423,790,818,400,817,402,812,401,815,402,810,403,813,402,422,783,822,399,814,405,806,407,423,15184,1869,288,485,332,478,341,446,368,442,373,425,385,425,390,419,390,428,380,427,385,418,390,422,4038,827,392,819,400,422,790,817,400,425,783,820,397,432,786,433,780,435,778,822,399,814,394,425,790,432,782,429,788,818,394,828,390,816,399,811,407,418,790,432,783,816,400,819,398,422,790,823,392,424,785,820,398,427,785,820,399,814,400,422,792,817,396,425,793,815,401,424,790,423,786,429,784,829,392,424,787,425,794,425,790,803,415,420,789,427,781,438,779,819,399,818,392,815,410,810,404,809,400,814,401,421,792,816,403,812,402,817,395,425,788,824,399,802,411,810,402,814,403,806,405,814,405,421,790,817,400,807,411,806,405,417,15264,1869,211,498,326,464,352,443,372,433,380,432,382,422,389,421,386,424,384,423,390,423,384,423,4028,842,388,827,392,429,786,818,390,430,785,827,399,419,785,431,785,428,783,823,396,816,402,429,784,424,785,436,773,826,393,823,397,820,394,819,396,428,781,428,789,817,397,821,393,423,800,812,398,423,788,815,403,423,789,817,400,811,403,421,789,816,405,424,786,819,401,423,781,433,784,437,779,820,398,426,785,432,785,421,792,814,400,430,787,425,785,432,786,814,400,813,400,820,396,813,403,814,402,812,396,427,786,820,405,807,403,813,398,429,782,822,401,810,401,819,396,815,400,817,400,812,401,423,790,818,391,817,406,811,402,418,10132,8554,277,503,317,157,

button 2

400,821,398,422,782,823,393,426,10890,7848,233,498,315,465,357,428,382,426,388,428,382,425,381,421,384,431,376,436,4011,482,747,445,783,442,764,830,393,444,764,826,392,443,766,436,784,823,398,424,777,829,394,820,400,818,389,436,774,432,783,441,776,437,780,431,777,450,772,829,385,840,372,438,771,828,386,850,366,438,774,436,777,841,376,439,785,816,388,441,770,838,383,823,399,813,392,442,782,425,783,433,789,816,391,446,761,448,768,442,774,824,400,434,777,439,775,435,772,833,386,829,387,817,398,824,389,830,388,827,385,429,781,830,397,818,385,830,386,430,780,824,395,823,389,835,386,817,393,828,392,426,780,831,393,810,403,431,776,818,401,435,8846,9805,306,474,344,449,373,424,393,431,370,425,388,425,391,416,398,406,396,416,4035,453,771,439,777,432,792,813,396,425,793,811,402,427,777,441,773,823,403,424,781,814,412,810,401,813,407,421,779,430,793,435,773,437,781,441,767,435,780,825,395,818,396,428,793,807,399,826,388,441,768,439,767,838,396,432,774,820,402,420,787,826,390,826,388,837,373,436,782,432,779,428,790,812,398,443,769,441,785,423,786,818,401,436,770,436,789,422,783,833,387,837,377,829,386,818,397,819,393,815,408,408,799,818,404,806,394,812,415,419,788,822,397,815,393,828,394,815,406,818,382,437,780,819,392,818,398,428,785,830,389,427,9200,8793,161,525,289,467,353,455,361,433,372,429,390,427,382,419,395,422,384,429,380,418,4032,468,751,451,776,446,769,829,386,434,772,835,388,426,786,433,780,831,386,431,780,829,393,816,402,819,394,427,784,425,783,435,779,440,777,433,782,446,770,818,402,812,398,425,782,828,393,824,395,433,773,438,783,818,392,439,795,807,397,426,789,817,393,815,398,822,399,426,777,442,775,427,789,822,395,427,789,419,791,442,775,824,394,420,794,423,790,425,785,824,399,813,391,821,406,804,408,823,383,818,394,433,788,820,399,815,396,823,402,409,792,824,395,815,398,833,385,811,400,818,405,429,773,822,391,831,393,426,780,831,390,426,10977,7664,328,468,351,444,377,431,382,429,368,438,380,432,374,434,378,426,391,423,4020,489,734,461,759,447,772,831,385,428,789,815,403,422,

389,427,786,425,788,832,385,425,790,436,774,823,395,435,776,827,389,424,786,431,785,826,392,437,776,816,406,816,394,821,397,430,782,431,791,813,398,814,399,426,787,431,779,825,393,829,386,818,401,811,406,817,396,431,779,431,791,427,781,818,405,416,791,435,778,430,789,824,389,433,779,432,785,437,779,814,407,816,391,817,405,814,399,814,404,804,410,430,782,809,400,818,402,812,401,420,797,807,411,803,409,807,403,820,396,818,396,425,785,833,388,818,395,429,786,818,402,419,10994,7000,156,524,306,462,355,436,387,416,399,413,390,414,394,435,373,427,384,429,378,429,4024,466,757,447,779,423,791,444,768,826,390,430,783,826,392,436,783,429,785,819,397,429,787,427,778,824,391,436,780,821,399,426,789,435,778,819,397,428,783,819,401,824,390,817,399,428,784,430,782,818,397,818,402,427,791,427,790,814,388,821,401,819,391,819,398,818,400,433,781,417,796,431,781,820,397,429,786,428,783,428,794,807,405,419,797,426,787,435,774,827,388,815,403,823,390,820,406,808,396,825,391,425,789,823,394,825,392,816,396,429,788,814,400,819,394,812,405,821,397,811,400,425,791,814,402,810,407,424,790,808,408,418,10611,7361,188,513,305,466,353,443,369,432,386,424,389,426,382,424,389,426,382,424,389,422,4026,461,765,431,783,439,781,438,777,817,400,424,791,826,378,436,785,435,778,827,395,425,788,428,783,826,390,436,776,827,391,433,784,427,786,819,399,424,787,822,391,825,394,818,400,423,785,435,781,825,387,819,410,422,786,430,787,813,398,824,390,815,404,819,396,815,390,429,790,425,784,439,777,818,402,431,786,427,779,434,787,815,401,424,792,424,788,430,775,822,408,807,404,816,389,823,403,811,402,809,407,421,791,815,404,821,393,813,399,426,794,815,395,815,399,814,403,812,404,811,403,418,798,814,395,819,398,424,794,807,411,412,12202,5719,238,528,297,454,356,445,378,422,391,421,388,420,388,424,387,430,378,425,387,418,4036,451,773,434,780,440,776,430,782,824,400,424,780,824,399,430,783,425,788,819,401,423,788,427,786,827,387,433,787,812,402,428,798,412,788,820,399,432,772,829,395,821,388,819,402,418,790,435,779,825,396,

This comment has been minimized.

Copy link
@Martin-Laclaustra

Martin-Laclaustra Dec 18, 2018

I only have some generic tips:

  1. For starters stick with only one button. Forget the rest until you have that cracked.
  2. Get "loads" of data with SimpleRcScanner. Tweak the sketch in "SAMPLESIZE 500" to as much as your chip ram memory can hold. Think of 2000 - 5000. Press the button steadily during all the capture time.
  3. Inspect data manually. Replace "," with newlines. Separate "trains of pulses" identifying syncs. I could see in your data some starting with 10000+8000 and others with 15000+2000. Paste all trains identified (in order) in consecutive columns in a spreadsheet. That will allow to: a) get the length of the pulses; b) compare them; c) find a repeating pattern.
  4. Use transmittimingsarray for a sequence as long as you need so you repeat your whole pattern (several trains together).

I looked at your "on". Two very similar trains starting with 10000+8000, followed by a third 10000+8000 with some differences (capturing errors?), followed by 3 repeats of equal trains 15000+2000, and after that a start of one 10000+8000 which was truncated. You need more data. But you will have to look at it yourself. Search for the repetition of patterns.
You can easily compare columns with this formula: =SQRT(VAR(A1:B1)). Values under 25 could be considered for equality. Use your judgement.

johnou added a commit to johnou/OpenMQTTGateway that referenced this pull request Dec 17, 2018

Fix compile error
Introduced with 1technophile#313

@johnou johnou referenced this pull request Dec 17, 2018

Merged

Fix compile error #330

1technophile added a commit that referenced this pull request Dec 17, 2018

ettiennegous added a commit to ettiennegous/OpenMQTTGateway that referenced this pull request May 24, 2019

Master (#1)
* ESPilight support

Support for ESPilight - only recieve at the moment

* Adjustments for sending Pilight messages including RAW messages

https://manual.pilight.org/programs/debug.html
https://manual.pilight.org/programs/raw.html

Considering a RAW receive handler

* Fixup callback and loop for Pilight - catches all messages per loop

* Update Test_config.h

* Added ESPilight libs

* change default DHT pin for ESP32

following user feedback pin 16 works and 35 doesn't works

* correct impossibility to read value with HM10

1technophile#281 and make the code more flexible (deduct an offset from a key value instead of fixed offset)

*  Increased size of mqtt_pass to char[30]  (1technophile#288)

* Increased size of mqtt_pass to char[30]

* modified test_config.h too

* Fixed typo and added a little formatting (1technophile#290)

* Introduced WifiManager_ssid variable and documented user_config.h (1technophile#289)

* Commented user_config.h to clarify usage of WifiManager

* Introduced WifiManager_ssid variable

* Added changes to Test_config.h too

* multi gpio input module (1technophile#278)


* GPIOKeyCode module added

* Add Home Assistant MQTT room presence support (ESP32 only) (1technophile#294)

* Add Home Assistant MQTT room presence support

ESP32 only

* Publish refactoring (1technophile#298)

* factoring of the publishing function
* integration of json publishing to MQTT
* receiving and transcode json messages from mqtt
* replace the TRACE runtime condition by a buildtime one so as to decrease program size
* remove retainFlag parameter not necessary for the moment
* Increase the scope of tests for arduino mega and esp32
* Update arduinojson library to 5.13.3
* add macros to choose between simple or json publishing or both
* differentiate build test for ATmega2560
* correct wrong sprintf definition
* change IDE version for continuous integration
* let default warning level in arduino ide
* correct pins for ESP32
* reorganize user_config

* remove unecessary variable and PilighttoMQTT call

* Update README.md

* remove redundant code for home presence (1technophile#303)

* correct duplicate comments and code

* fix ESP32 ble (1technophile#304)

* remove redundant code for home presence

* hopefully fix ESP32 BLE hangs

* basic support for duplicate detection when JSON publishing is active

* correct double variable declaration and use arduino json implicit cast

* Update ZgatewayRF2.ino (1technophile#309)

Small fix for dimming with JSON payload.
switchType 0 OFF
switchType 1 ON
switchType 2 DIM
{
"switchType": 2,
"adress": "26494598",
"unit": 10,
"dim": 8
}

* correct sonoff rf bridge issue not communicating with RF module

1technophile#310

* update rc-switch (1technophile#313)

* more repeatSRFBwMQTT macro to pertinent config file

1technophile#295

* Update contributor list

* Add images

* add missing macro

* update esppilight lib

content of the library is not filtered on 433mhz only

* Mqtt discovery (1technophile#320)

* add mqtt discovery (compatibile with home assistant) with omg status binary sensor & bme280 sensor

* added mqtt discovery to Test_config.h for ESP32 (ESP8266 & other boards was not tested)

* include support for ESP8266 & arduino mega

* fix getting MAC for esp8266

* esp8266 fix

* make mqtt discovery functions functions more generic, readable and easy to use & extend

* make mqtt discovery functions functions more generic, readable and easy to use & extend PART 2

* remove the macro for each attribute and supposing that if there is a bme280 we expose all

* remove unecessaries files from pilight lib

* move MQTT_MAX_PACKET_SIZE to pubsubclient library

* per default deactivate mqtt ha discovery

* wdt tip add and presence detection improvments

-improve distance measurement
-add wdt prevent tip
-add conditional macro haroompresence

* Mqtt discovery for ha (1technophile#323)

* MQTT discovery factoring

* add DHT discovery

* BME topic macro change

* add sensors to ha discovery

* correct a comment typo 1technophile#327

* let the possibility at buildtime to don't publish service data

* reduce string usage

* change MQTT ONOFF actuator to ON OFF commands instead of true false

* add ZactuatorONOFF discovery

* add simple publishing for GPIO input

* Add RF switch and gateway discovery

* fix typo mistake

1technophile#324

* Fix compile error (1technophile#330) on rcswitch

Introduced with 1technophile#313

* Default pin for ESP8266 should be RX (1technophile#332)

* code cleanup and improvment (1technophile#339)

* replace string by char array comparison

* take mac adress from user_config for arduino ethernet shield

* remove code for managing HM10 with version < v6xx

* add sys measure call for arduino mega

* code size decrease and optim

* differentiate receiving and publishing mqtt for the new json option in user_config.h

1technophile#318 so as to avoid user with non modified controllers to have regression on receiving (per default receiving is activated for both json and simple and prioritary analysed for json)

* Storevalue after pub to avoid duplicates publishing in slow environment

* add per default Irremote protocol for arduino mega

as the mega can handle the list without memory issue (contrary to the uno)
set default mega pinout

* set default protocol with to IR NEC when no protocol is set on json

* differentiate ON OFF pin depending on board

* remove cleanFS macro and correct reseting when mqtt fail at start

clean FS now available from Arduino IDE tools menu (erase flash)

* add some image ressources

* add wifimanager config portal timeout

1technophile#350 in case of power outage so as to avoid to pop up the web page before the mqtt server restart

* add specific pinout for RF on arduino mega

* traces improvements, and code refactoring (RF315)

* enable the link between OMG status and its components

enable to have the link between OMG status and its sensors/gateways on the same place for HASS
https://community.openmqttgateway.com/t/v0-9beta-testers-needed/242/2?u=1technophile

* Update OpenMQTTGateway.ino

* put RF EMITTER PIN according to doc

* Update CONTRIBUTING.md

* Update IRRemoteESP8266 version to 2.5.5
factorize IR send signal function between the 2 types of receiving
Add new IRRemoteESP8266 protocols
replace pins on mega according schema
remove unecessaries spaces

* Update ESPilight library to 0.16.0

tfa protocol
kerui protocol

* Enable to switch HM1X led by a macro

1technophile#357
if //#define HM_BLUE_LED_STOP true uncommented
the HM1X led is off

* add log output through mqtt

1technophile#135
//#define subjectTRACEtoMQTT Base_Topic Gateway_Name "/log" //uncomment if you want to see traces on /log topic

* change default pin for rf receiver on ESP32

13 seems to don't work

* Add LORA gateway

first implementation of a lora gateway integration, tested on ttgo heltec boards with embedded lora module 1technophile#356
Sending and receiving working

* Update README.md

* Update README.md

* add LORA gateway parameters

following lora api library def
https://github.com/sandeepmistry/arduino-LoRa/blob/master/API.md

* a first try for mi flora and mi jia auto discovery on hass

1technophile#361

* add LORA gateway auto discovery

* Some memory optimization for Arduino UNO following this thread:
https://community.openmqttgateway.com/t/arduino-uno-ethernet-shield-reboots-on-receiving-rf-signal-on-v-0-9/346/22
Rework led management to avoid use of global variables
and specify special JSON_MSG_BUFFER for arduino UNO
led can now be used for all the boards

generalize use of F macro
for memory optimization
change jsonbuffer calculation method
reduce pubsubclient max packet size for uno and nano

* Update README.md

* no need of going >67 as the code can handle only unsigned long at this time

* Add "repeat" field to RF JSON messages. (1technophile#372)

* update pubsubclient release to 2.7

* update irremote ESP8266 to 2.5.6

* publish discovery for sensors BLE once per run, add ble white and black list
Avoid publishing auto discovery on a time basis
publish auto discovery only one time per BLE sensor
add BLE white and black list implementation
set black list
mosquitto_pub -t home/OpenMQTTGateway/commands/MQTTtoBT/set -m '{"black-list":["012314551615","4C6577889C79","edfrgtyjulik"]}'
set white list
mosquitto_pub -t home/OpenMQTTGateway/commands/MQTTtoBT/set -m '{"white-list":["012314551615","4C65A5553C79","edfrgtyjulik"]}'

* remove optimistic and retain flag from auto discovery

1technophile#361

and add some json buffer size to avoid identifier lost

* correct json buffer size optimizations

* correct switch between modes raw versus message + protocol and add raw error codes (1technophile#374)

has been discussed here:
puuu/ESPiLight#39

* Add pilight repeater function

1technophile#369
set
#define repeatPilightwMQTT true
into config_RF.h to activate it

* add comment for sonoff rf bridge IR add

* Separate list of contributors for main file reading improvment

add also missing contributors

* correct deduplication issue with SRFB and improve OMG performance

by reducing the receivingMQTT call numbers
https://community.openmqttgateway.com/t/seeing-duplicated-messages/398/7

* Correct return always false when using HM10 and return number instead of char array for sensors values

* add message if wrong pubsubclient library used

* correct isue with using a different receiver with RFM69 than the default and ack issue

1technophile#376 1technophile#375

* revert thigh and tlow for sonoff rf bridge SRFBtoMQTT

1technophile#366

* correct wrong json object name

* change actuator default assignment

* change default input gpio pin

* add comment for sonoff pin

* Prepare 0.9.1 release

* Add LORA to functions schema
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.