Browse Source

Merge branch 'dev' into softcfg

v2
Xose Pérez 6 years ago
parent
commit
c9d99c9ff4
28 changed files with 3486 additions and 3143 deletions
  1. +39
    -0
      CHANGELOG.md
  2. +21
    -10
      README.md
  3. +7
    -2
      code/build.sh
  4. +1
    -1
      code/eagle.flash.1m0m1s.ld
  5. +3
    -3
      code/eagle.flash.1m0m2s.ld
  6. +20
    -0
      code/eagle.flash.2m1m4s.ld
  7. +1
    -1
      code/eagle.flash.4m1m4s.ld
  8. +1
    -1
      code/eagle.flash.4m3m4e.ld
  9. +1
    -1
      code/eagle.flash.512k0m1s.ld
  10. +73
    -29
      code/espurna/alexa.ino
  11. +3
    -0
      code/espurna/config/arduino.h
  12. +4
    -0
      code/espurna/config/device.h
  13. +1
    -1
      code/espurna/config/version.h
  14. BIN
      code/espurna/data/index.all.html.gz
  15. +90
    -2
      code/espurna/device.ino
  16. +3
    -2
      code/espurna/ir.ino
  17. +19
    -17
      code/espurna/pwm.c
  18. +10
    -2
      code/espurna/sensors/DHTSensor.h
  19. +3097
    -3053
      code/espurna/static/index.all.html.gz.h
  20. +0
    -4
      code/espurna/utils.ino
  21. +0
    -4
      code/extra_scripts.py
  22. +3
    -3
      code/gulpfile.js
  23. +8
    -2
      code/ota.py
  24. +81
    -5
      code/platformio.ini
  25. BIN
      images/devices/ag-l4.jpg
  26. BIN
      images/devices/allterco-shelly1.jpg
  27. BIN
      images/devices/homecube-16a.jpg
  28. BIN
      images/devices/lohas-9w.jpg

+ 39
- 0
CHANGELOG.md View File

@ -3,6 +3,45 @@
The format is based on [Keep a Changelog](http://keepachangelog.com/) The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/). and this project adheres to [Semantic Versioning](http://semver.org/).
## [1.13.2] 2018-08-27
### Fixed
- Fix relay overflow window length
- Fix TravisCI release condition (thanks to @mcspr, [#1042](https://github.com/xoseperez/espurna/issues/1042))
- Fix Sonoff RFBridge build in Arduino IDE ([#1043](https://github.com/xoseperez/espurna/issues/1043))
- Using corrent path separator in gulpfile.js (thanks to @InduPrakash, [#1045](https://github.com/xoseperez/espurna/issues/1045))
- Fix KMC70011 LED logic (thanks to @zerog2k, [#1056](https://github.com/xoseperez/espurna/issues/1056))
- Fix Luani HVIO to use 1MB flash size and toggle switch (thanks to @BauerPh, [#1065](https://github.com/xoseperez/espurna/issues/1065) and [#1068](https://github.com/xoseperez/espurna/issues/1068))
- Fix switches in Microsoft Edge (thanks to @Valcob, [#1066](https://github.com/xoseperez/espurna/issues/1066))
- Fix build.sh error handling (thanks to @mcspr, [#1075](https://github.com/xoseperez/espurna/issues/1075))
- Correctly init Serial on RELAY_PROVIDER_STM ([#1130](https://github.com/xoseperez/espurna/issues/1130))
- Disconnect before running WPS and SmartConfig discovery ([#1146](https://github.com/xoseperez/espurna/issues/1146))
- Fix sort fields in OTA manager
### Added
- Support for YJZK 1Ch and 3CH switches (thanks to @CollinShorts and @q32103940, [#1047](https://github.com/xoseperez/espurna/issues/1047))
- Support for AG-L4 color desk lamp (thanks to @zerog2k, [#1050](https://github.com/xoseperez/espurna/issues/1050))
- Option to cofigure ON/OFF payload at build time ([#1085](https://github.com/xoseperez/espurna/issues/1085))
- Option to change default payload for HA ([#1085](https://github.com/xoseperez/espurna/issues/1085))
- Support for Allterco Shelly1 (thanks to @abmantis, [#1128](https://github.com/xoseperez/espurna/issues/1128))
- Support for HomeCube 16A (thanks to @hyteoo, [#1106](https://github.com/xoseperez/espurna/issues/1106))
- Support for multiple sonar sensors (thanks to @ruimarinho, [#1116](https://github.com/xoseperez/espurna/issues/1116))
- Support for hardware serial on PMSX003 device (thanks to @ruimarinho, [#1122](https://github.com/xoseperez/espurna/issues/1122))
- Support for Lohas 9W bulbs (thanks to @steveway, [#1135](https://github.com/xoseperez/espurna/issues/1135))
- Show literal for webUI image in info ([#1142](https://github.com/xoseperez/espurna/issues/1142))
- Add RFBRIDGE code to full webUI image ([#1157](https://github.com/xoseperez/espurna/issues/1157))
- Handle events in EventSensor
- Option to remove API_SUPPORT at build time
- Option to save total energy in EEPROM after X reports, disabled by default
- Support for DHT12 sensor (thanks to Altan Altay)
- Support for 2MB flash boards
### Changed
- Update PlatformIO support to 3.6.X branch
- Explicitly disable ATC on RFM69 gateway ([#938](https://github.com/xoseperez/espurna/issues/938))
- Reduce memory footprint of API calls ([#1133](https://github.com/xoseperez/espurna/issues/1133))
- Init relay GPIO when in inverse mode to be OFF ([#1078](https://github.com/xoseperez/espurna/issues/1078))
## [1.13.1] 2018-07-10 ## [1.13.1] 2018-07-10
### Fixed ### Fixed
- Build issues with Arduino IDE ([#975](https://github.com/xoseperez/espurna/issues/975)) - Build issues with Arduino IDE ([#975](https://github.com/xoseperez/espurna/issues/975))


+ 21
- 10
README.md View File

@ -3,7 +3,7 @@
ESPurna ("spark" in Catalan) is a custom firmware for ESP8285/ESP8266 based smart switches, lights and sensors. ESPurna ("spark" in Catalan) is a custom firmware for ESP8285/ESP8266 based smart switches, lights and sensors.
It uses the Arduino Core for ESP8266 framework and a number of 3rd party libraries. It uses the Arduino Core for ESP8266 framework and a number of 3rd party libraries.
[![version](https://img.shields.io/badge/version-1.13.2c-brightgreen.svg)](CHANGELOG.md)
[![version](https://img.shields.io/badge/version-2.0.0RC1-brightgreen.svg)](CHANGELOG.md)
[![branch](https://img.shields.io/badge/branch-softcfg-orange.svg)](https://github.com/xoseperez/espurna/tree/softcfg/) [![branch](https://img.shields.io/badge/branch-softcfg-orange.svg)](https://github.com/xoseperez/espurna/tree/softcfg/)
[![travis](https://travis-ci.org/xoseperez/espurna.svg?branch=softcfg)](https://travis-ci.org/xoseperez/espurna) [![travis](https://travis-ci.org/xoseperez/espurna.svg?branch=softcfg)](https://travis-ci.org/xoseperez/espurna)
[![codacy](https://img.shields.io/codacy/grade/c9496e25cf07434cba786b462cb15f49/softcfg.svg)](https://www.codacy.com/app/xoseperez/espurna/dashboard) [![codacy](https://img.shields.io/codacy/grade/c9496e25cf07434cba786b462cb15f49/softcfg.svg)](https://www.codacy.com/app/xoseperez/espurna/dashboard)
@ -15,6 +15,12 @@ It uses the Arduino Core for ESP8266 framework and a number of 3rd party librari
--- ---
## Contributors
**Without your help this project would not be possible**. I (@xoseperez) simply can't spend all the time I wish on ESPurna but luckly I recieve a lot of contributions, bug fixes, enhancement suggestions,... from people all around the world. I would like to thank you each and every one of you. The [contributors](https://github.com/xoseperez/espurna/graphs/contributors) page shows the ones that have done a PR in the past, but I also get contributions in the issues, by email or via the [gitter ESPurna channel](https://gitter.im/tinkerman-cat/espurna), those I also want to thank.
**Thank you all very much**.
## Notice ## Notice
> Please use the [gitter ESPurna channel](https://gitter.im/tinkerman-cat/espurna) for support and questions, you have better chances to get fast answers from me or other ESPurna users. Open an issue here only if you feel there is a bug or you want to request an enhancement. Thank you. > Please use the [gitter ESPurna channel](https://gitter.im/tinkerman-cat/espurna) for support and questions, you have better chances to get fast answers from me or other ESPurna users. Open an issue here only if you feel there is a bug or you want to request an enhancement. Thank you.
@ -68,7 +74,7 @@ It uses the Arduino Core for ESP8266 framework and a number of 3rd party librari
* Support for [direct control of the encoder/decoder bypassing the EFM8BB1](https://github.com/xoseperez/espurna/wiki/Hardware-Itead-Sonoff-RF-Bridge---Direct-Hack) * Support for [direct control of the encoder/decoder bypassing the EFM8BB1](https://github.com/xoseperez/espurna/wiki/Hardware-Itead-Sonoff-RF-Bridge---Direct-Hack)
* Support for [different **sensors**](Sensors) * Support for [different **sensors**](Sensors)
* Environment * Environment
* **DHT11 / DHT22 / DHT21 / AM2301 / Itead's SI7021**
* **DHT11 / DHT12 / DHT22 / DHT21 / AM2301 / Itead's SI7021**
* **BMP280** and **BME280** temperature, humidity (BME280) and pressure sensor by Bosch * **BMP280** and **BME280** temperature, humidity (BME280) and pressure sensor by Bosch
* **TMP35** and **TMP36** analog temperature sensors * **TMP35** and **TMP36** analog temperature sensors
* **NTC** temperature sensors * **NTC** temperature sensors
@ -82,6 +88,7 @@ It uses the Arduino Core for ESP8266 framework and a number of 3rd party librari
* **BH1750** luminosity sensor * **BH1750** luminosity sensor
* **GUVAS12SD** UV sensor * **GUVAS12SD** UV sensor
* **GEIGER COUNTER** by RH Electronics * **GEIGER COUNTER** by RH Electronics
* **HC-SR04**, **SRF05**, **SRF06**, **DYP-ME007**, **JSN-SR04T** & **Parallax PING)))™** distance sensors
* Power monitoring * Power monitoring
* **HLW8012** using the [HLW8012 Library](https://bitbucket.org/xoseperez/hlw8012) (Sonoff POW) * **HLW8012** using the [HLW8012 Library](https://bitbucket.org/xoseperez/hlw8012) (Sonoff POW)
* **CSE7766** and **CSE7759B** power monitor chips * **CSE7766** and **CSE7759B** power monitor chips
@ -89,8 +96,8 @@ It uses the Arduino Core for ESP8266 framework and a number of 3rd party librari
* Non-invasive **current sensor** using **internal ADC** or **ADC712** or **ADC121** or **ADS1115** * Non-invasive **current sensor** using **internal ADC** or **ADC712** or **ADC121** or **ADS1115**
* **V9261F** power monitor chip * **V9261F** power monitor chip
* **PZEM0004T** power monitor board * **PZEM0004T** power monitor board
* Raw analog and digital sensors
* Simple pulse counter
* Raw **analog** and **digital** sensors
* Simple **pulse counter** with **event triggering** option
* Support for (almost) any UART based sensor via the **UART-to-MQTT module** * Support for (almost) any UART based sensor via the **UART-to-MQTT module**
* Support for different units (Fahrenheit or Celsius, Watts or Kilowatts, Joules or kWh) * Support for different units (Fahrenheit or Celsius, Watts or Kilowatts, Joules or kWh)
* Support for LED lights * Support for LED lights
@ -228,16 +235,18 @@ Here is the list of supported hardware. For more information please refer to the
|**Schuko Wifi Plug**|**KMC 70011**|**Xenon SM-PW702U**| |**Schuko Wifi Plug**|**KMC 70011**|**Xenon SM-PW702U**|
|![Maxcio W-US002S](images/devices/maxcio-w-us002s.jpg)|![HEYGO HY02](images/devices/heygo-hy02.jpg)|![YiDian XS-SSA05](images/devices/yidian-xs-ssa05.jpg)| |![Maxcio W-US002S](images/devices/maxcio-w-us002s.jpg)|![HEYGO HY02](images/devices/heygo-hy02.jpg)|![YiDian XS-SSA05](images/devices/yidian-xs-ssa05.jpg)|
|**Maxcio W-US002S**|**HEYGO HY02**|**YiDian XS-SSA05**| |**Maxcio W-US002S**|**HEYGO HY02**|**YiDian XS-SSA05**|
|![WiOn 50055](images/devices/wion-50055.jpg)|![LINGAN SWA1](images/devices/lingan-swa1.jpg)||
|**WiOn 50055**|**LINGAN SWA1**||
|![WiOn 50055](images/devices/wion-50055.jpg)|![LINGAN SWA1](images/devices/lingan-swa1.jpg)|![HomeCube 16A](images/devices/homecube-16a.jpg)|
|**WiOn 50055**|**LINGAN SWA1**|**HomeCube 16A**|
|![Tonbux PowerStrip02](images/devices/tonbux-powerstrip02.jpg)|![ForNorm Power Strip](images/devices/fornorm-power-strip.jpg)|![Zhilde ZLD-EU55-W](images/devices/zhilde-zld-eu55-w.jpg)| |![Tonbux PowerStrip02](images/devices/tonbux-powerstrip02.jpg)|![ForNorm Power Strip](images/devices/fornorm-power-strip.jpg)|![Zhilde ZLD-EU55-W](images/devices/zhilde-zld-eu55-w.jpg)|
|**Tonbux PowerStrip02**|**Fornorm Power Strip**|**Zhilde ZLD-EU55-W**| |**Tonbux PowerStrip02**|**Fornorm Power Strip**|**Zhilde ZLD-EU55-W**|
|![Itead Sonoff Touch](images/devices/itead-sonoff-touch.jpg)|![Itead Sonoff T1](images/devices/itead-sonoff-t1.jpg)|![YJZK 2-gang switch](images/devices/yjzk-2gang-switch.jpg)|
|**Itead Sonoff Touch**|**Itead Sonoff T1**|**YJZK 2-gang switch**|
|![Itead Sonoff Touch](images/devices/itead-sonoff-touch.jpg)|![Itead Sonoff T1](images/devices/itead-sonoff-t1.jpg)|![YJZK switch](images/devices/yjzk-2gang-switch.jpg)|
|**Itead Sonoff Touch**|**Itead Sonoff T1**|**YJZK 1/2/3-gangs switch**|
|![Itead Slampher](images/devices/itead-slampher.jpg)|![Arilux E27](images/devices/arilux-e27.jpg)|![Itead Sonoff B1](images/devices/itead-sonoff-b1.jpg)| |![Itead Slampher](images/devices/itead-slampher.jpg)|![Arilux E27](images/devices/arilux-e27.jpg)|![Itead Sonoff B1](images/devices/itead-sonoff-b1.jpg)|
|**Itead Slampher**|**Arilux E27**|**Itead Sonoff B1**| |**Itead Slampher**|**Arilux E27**|**Itead Sonoff B1**|
|![AI-Thinker Wifi Light / Noduino OpenLight](images/devices/aithinker-ai-light.jpg)|![Authometion LYT8266](images/devices/authometion-lyt8266.jpg)||
|**AI-Thinker Wifi Light / Noduino OpenLight**|**Authometion LYT8266**||
|![AI-Thinker Wifi Light / Noduino OpenLight](images/devices/aithinker-ai-light.jpg)|![Authometion LYT8266](images/devices/authometion-lyt8266.jpg)|![AG-L4](images/devices/ag-l4.jpg)|
|**AI-Thinker Wifi Light / Noduino OpenLight**|**Authometion LYT8266**|**AG-L4**|
|![Lohas 9W](images/devices/lohas-9w.jpg)|||
|**Lohas 9W**|||
|![Itead Sonoff LED](images/devices/itead-sonoff-led.jpg)|![Itead BN-SZ01](images/devices/itead-bn-sz01.jpg)|![InterMitTech QuinLED 2.6](images/devices/intermittech-quinled-2.6.jpg)| |![Itead Sonoff LED](images/devices/itead-sonoff-led.jpg)|![Itead BN-SZ01](images/devices/itead-bn-sz01.jpg)|![InterMitTech QuinLED 2.6](images/devices/intermittech-quinled-2.6.jpg)|
|**Itead Sonoff LED**|**Itead BN-SZ01**|**InterMitTech QuinLED 2.6**| |**Itead Sonoff LED**|**Itead BN-SZ01**|**InterMitTech QuinLED 2.6**|
|![Arilux AL-LC01 (RGB)](images/devices/arilux-al-lc01.jpg)|![Arilux AL-LC02 (RGBW)](images/devices/arilux-al-lc02.jpg)|![Arilux AL-LC06 (RGBWWCW)](images/devices/arilux-al-lc06.jpg)| |![Arilux AL-LC01 (RGB)](images/devices/arilux-al-lc01.jpg)|![Arilux AL-LC02 (RGBW)](images/devices/arilux-al-lc02.jpg)|![Arilux AL-LC06 (RGBWWCW)](images/devices/arilux-al-lc06.jpg)|
@ -248,6 +257,8 @@ Here is the list of supported hardware. For more information please refer to the
|**Itead Sonoff SV**|**Itead 1CH Inching**|**Itead Motor Clockwise/Anticlockwise**| |**Itead Sonoff SV**|**Itead 1CH Inching**|**Itead Motor Clockwise/Anticlockwise**|
|![Jan Goedeke Wifi Relay (NO/NC)](images/devices/jangoe-wifi-relay.jpg)|![Jorge García Wifi + Relays Board Kit](images/devices/jorgegarcia-wifi-relays.jpg)|![EXS Wifi Relay v3.1](images/devices/exs-wifi-relay-v31.jpg)| |![Jan Goedeke Wifi Relay (NO/NC)](images/devices/jangoe-wifi-relay.jpg)|![Jorge García Wifi + Relays Board Kit](images/devices/jorgegarcia-wifi-relays.jpg)|![EXS Wifi Relay v3.1](images/devices/exs-wifi-relay-v31.jpg)|
|**Jan Goedeke Wifi Relay (NO/NC)**|**Jorge García Wifi + Relays Board Kit**|**EXS Wifi Relay v3.1**| |**Jan Goedeke Wifi Relay (NO/NC)**|**Jorge García Wifi + Relays Board Kit**|**EXS Wifi Relay v3.1**|
|![Allterco Shelly1](images/devices/allterco-shelly1.jpg)|||
|**Alterco Shelly1**|||
|![ManCaveMade ESP-Live](images/devices/mancavemade-esp-live.jpg)|![Wemos D1 Mini Relay Shield](images/devices/wemos-d1-mini-relayshield.jpg)|![Witty Cloud](images/devices/witty-cloud.jpg)| |![ManCaveMade ESP-Live](images/devices/mancavemade-esp-live.jpg)|![Wemos D1 Mini Relay Shield](images/devices/wemos-d1-mini-relayshield.jpg)|![Witty Cloud](images/devices/witty-cloud.jpg)|
|**ManCaveMade ESP-Live**|**Wemos D1 Mini Relay Shield**|**Witty Cloud**| |**ManCaveMade ESP-Live**|**Wemos D1 Mini Relay Shield**|**Witty Cloud**|
|![IKE ESPike](images/devices/ike-espike.jpg)|![Pilotak ESP DIN](images/devices/pilotak-esp-din.jpg)|![Arniex Swifitch](images/devices/arniex-swifitch.jpg)| |![IKE ESPike](images/devices/ike-espike.jpg)|![Pilotak ESP DIN](images/devices/pilotak-esp-din.jpg)|![Arniex Swifitch](images/devices/arniex-swifitch.jpg)|


+ 7
- 2
code/build.sh View File

@ -10,6 +10,8 @@ is_git() {
} }
# Script settings # Script settings
destination=../firmware
version=$(grep APP_VERSION espurna/config/version.h | awk '{print $3}' | sed 's/"//g') version=$(grep APP_VERSION espurna/config/version.h | awk '{print $3}' | sed 's/"//g')
if is_git; then if is_git; then
@ -104,13 +106,13 @@ build_environments() {
platformio run --silent --environment $environment 2>/dev/null || exit 1 platformio run --silent --environment $environment 2>/dev/null || exit 1
stat -c %s .pioenvs/$environment/firmware.bin stat -c %s .pioenvs/$environment/firmware.bin
[[ "${TRAVIS_BUILD_STAGE_NAME}" = "Test" ]] || \ [[ "${TRAVIS_BUILD_STAGE_NAME}" = "Test" ]] || \
mv .pioenvs/$environment/firmware.bin ../firmware/espurna-$version/espurna-$version-$environment.bin
mv .pioenvs/$environment/firmware.bin $destination/espurna-$version/espurna-$version-$environment.bin
done done
echo "--------------------------------------------------------------" echo "--------------------------------------------------------------"
} }
# Parameters # Parameters
while getopts "lp" opt; do
while getopts "lpd:" opt; do
case $opt in case $opt in
l) l)
print_available print_available
@ -119,6 +121,9 @@ while getopts "lp" opt; do
p) p)
par_build=true par_build=true
;; ;;
d)
destination=$OPTARG
;;
esac esac
done done


+ 1
- 1
code/eagle.flash.1m0m1s.ld View File

@ -1,4 +1,4 @@
/* Flash Split for 1M chips */
/* Flash Split for 1M chips, no SPIFFS, 1 sector for EEPROM */
/* sketch 999KB */ /* sketch 999KB */
/* eeprom 4KB */ /* eeprom 4KB */
/* reserved 16KB */ /* reserved 16KB */


+ 3
- 3
code/eagle.flash.1m0m2s.ld View File

@ -1,4 +1,4 @@
/* Flash Split for 1M chips, no SPIFFS */
/* Flash Split for 1M chips, no SPIFFS, 2 sectors for EEPROM */
/* sketch 995KB */ /* sketch 995KB */
/* eeprom 8KB */ /* eeprom 8KB */
/* reserved 16KB */ /* reserved 16KB */
@ -13,7 +13,7 @@ MEMORY
PROVIDE ( _SPIFFS_start = 0x402FA000 ); PROVIDE ( _SPIFFS_start = 0x402FA000 );
PROVIDE ( _SPIFFS_end = 0x402FA000 ); PROVIDE ( _SPIFFS_end = 0x402FA000 );
PROVIDE ( _SPIFFS_page = 0 );
PROVIDE ( _SPIFFS_block = 0 );
PROVIDE ( _SPIFFS_page = 0x0 );
PROVIDE ( _SPIFFS_block = 0x0 );
INCLUDE "../ld/eagle.app.v6.common.ld" INCLUDE "../ld/eagle.app.v6.common.ld"

+ 20
- 0
code/eagle.flash.2m1m4s.ld View File

@ -0,0 +1,20 @@
/* Flash Split for 2M chips, ~1M SPIFFS, 4 sectors for EEPROM */
/* sketch 1019KB */
/* spiffs 992KB */
/* eeprom 16KB */
/* reserved 16KB */
MEMORY
{
dport0_0_seg : org = 0x3FF00000, len = 0x10
dram0_0_seg : org = 0x3FFE8000, len = 0x14000
iram1_0_seg : org = 0x40100000, len = 0x8000
irom0_0_seg : org = 0x40201010, len = 0xfeff0
}
PROVIDE ( _SPIFFS_start = 0x40300000 );
PROVIDE ( _SPIFFS_end = 0x403F8000 );
PROVIDE ( _SPIFFS_page = 0x100 );
PROVIDE ( _SPIFFS_block = 0x2000 );
INCLUDE "../ld/eagle.app.v6.common.ld"

+ 1
- 1
code/eagle.flash.4m1m4s.ld View File

@ -1,4 +1,4 @@
/* Flash Split for 4M chips */
/* Flash Split for 4M chips, ~1M for SPIFFS, 4 sectors for EEPROM */
/* sketch 1019KB */ /* sketch 1019KB */
/* empty/ota? 2048KB */ /* empty/ota? 2048KB */
/* spiffs 992KB */ /* spiffs 992KB */


+ 1
- 1
code/eagle.flash.4m3m4e.ld View File

@ -1,4 +1,4 @@
/* Flash Split for 4M chips */
/* Flash Split for 4M chips, ~3M for SPIFFS, 4 sectors for EEPROM */
/* sketch 1019KB */ /* sketch 1019KB */
/* spiffs 3040KB */ /* spiffs 3040KB */
/* eeprom 16KB */ /* eeprom 16KB */


+ 1
- 1
code/eagle.flash.512k0m1s.ld View File

@ -1,4 +1,4 @@
/* Flash Split for 512K chips */
/* Flash Split for 512K chips, no SPIFFS, 1 sector for EEPROM */
/* sketch 487KB */ /* sketch 487KB */
/* eeprom 4KB */ /* eeprom 4KB */
/* reserved 16KB */ /* reserved 16KB */


+ 73
- 29
code/espurna/alexa.ino View File

@ -13,13 +13,13 @@ Module key prefix: alx
#include <fauxmoESP.h> #include <fauxmoESP.h>
fauxmoESP alexa; fauxmoESP alexa;
struct AlexaDevChange {
AlexaDevChange(unsigned char device_id, bool state) : device_id(device_id), state(state) {};
unsigned char device_id = 0;
bool state = false;
};
#include <queue> #include <queue>
static std::queue<AlexaDevChange> _alexa_dev_changes;
typedef struct {
unsigned char device_id;
bool state;
unsigned char value;
} alexa_queue_element_t;
static std::queue<alexa_queue_element_t> _alexa_queue;
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// ALEXA // ALEXA
@ -28,12 +28,12 @@ static std::queue<AlexaDevChange> _alexa_dev_changes;
#if WEB_SUPPORT #if WEB_SUPPORT
void _alexaWebSocketOnSend(JsonObject& root) { void _alexaWebSocketOnSend(JsonObject& root) {
root["alxVisible"] = 1; root["alxVisible"] = 1;
root["alxEnabled"] = getSetting("alxEnabled", ALEXA_ENABLED).toInt() == 1;
root["alxEnabled"] = alexaEnabled();
} }
#endif #endif
void _alexaConfigure() { void _alexaConfigure() {
alexa.enable(getSetting("alxEnabled", ALEXA_ENABLED).toInt() == 1);
alexa.enable(wifiConnected() && alexaEnabled());
} }
bool _alexaKeyCheck(const char * key) { bool _alexaKeyCheck(const char * key) {
@ -47,6 +47,10 @@ void _alexaBackwards() {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool alexaEnabled() {
return (getSetting("alexaEnabled", ALEXA_ENABLED).toInt() == 1);
}
void alexaSetup() { void alexaSetup() {
// Check backwards compatibility // Check backwards compatibility
@ -55,31 +59,58 @@ void alexaSetup() {
// Load & cache settings // Load & cache settings
_alexaConfigure(); _alexaConfigure();
// Uses hostname as base name for all devices
// TODO: use custom switch name when available
String hostname = getSetting("hostname");
// Lights
#if RELAY_PROVIDER == RELAY_PROVIDER_LIGHT
// Global switch
alexa.addDevice(hostname.c_str());
// For each channel
for (unsigned char i = 1; i <= lightChannels(); i++) {
alexa.addDevice((hostname + " " + i).c_str());
}
// Relays
#else
unsigned int relays = relayCount();
if (relays == 1) {
alexa.addDevice(hostname.c_str());
} else {
for (unsigned int i=1; i<=relays; i++) {
alexa.addDevice((hostname + " " + i).c_str());
}
}
#endif
// Callback
alexa.onSetState([&](unsigned char device_id, const char * name, bool state, unsigned char value) {
alexa_queue_element_t element;
element.device_id = device_id;
element.state = state;
element.value = value;
_alexa_queue.push(element);
});
// Websockets // Websockets
#if WEB_SUPPORT #if WEB_SUPPORT
wsOnSendRegister(_alexaWebSocketOnSend); wsOnSendRegister(_alexaWebSocketOnSend);
wsOnAfterParseRegister(_alexaConfigure); wsOnAfterParseRegister(_alexaConfigure);
#endif #endif
unsigned int relays = relayCount();
String hostname = getHostname();
if (relays == 1) {
alexa.addDevice(hostname.c_str());
} else {
for (unsigned int i=0; i<relays; i++) {
alexa.addDevice((hostname + "_" + i).c_str());
// Register wifi callback
wifiRegister([](justwifi_messages_t code, char * parameter) {
if ((MESSAGE_CONNECTED == code) || (MESSAGE_DISCONNECTED == code)) {
_alexaConfigure();
} }
}
alexa.onSetState([&](unsigned char device_id, const char * name, bool state) {
AlexaDevChange change(device_id, state);
_alexa_dev_changes.push(change);
});
alexa.onGetState([](unsigned char device_id, const char * name) {
return relayStatus(device_id);
}); });
// Settings
settingsRegisterKeyCheck(_alexaKeyCheck); settingsRegisterKeyCheck(_alexaKeyCheck);
// Register loop // Register loop
@ -91,11 +122,24 @@ void alexaLoop() {
alexa.handle(); alexa.handle();
while (!_alexa_dev_changes.empty()) {
AlexaDevChange& change = _alexa_dev_changes.front();
DEBUG_MSG_P(PSTR("[ALEXA] Device #%u state: %s\n"), change.device_id, change.state ? "ON" : "OFF");
relayStatus(change.device_id, change.state);
_alexa_dev_changes.pop();
while (!_alexa_queue.empty()) {
alexa_queue_element_t element = _alexa_queue.front();
DEBUG_MSG_P(PSTR("[ALEXA] Device #%u state: %s value: %d\n"), element.device_id, element.state ? "ON" : "OFF", element.value);
#if RELAY_PROVIDER == RELAY_PROVIDER_LIGHT
if (0 == element.device_id) {
relayStatus(0, element.state);
} else {
lightState(element.device_id - 1, element.state);
lightChannel(element.device_id - 1, element.value);
lightUpdate(true, true);
}
#else
relayStatus(element.device_id, element.state);
#endif
_alexa_queue.pop();
} }
} }


+ 3
- 0
code/espurna/config/arduino.h View File

@ -110,8 +110,11 @@
//#define BH_ONOFRE //#define BH_ONOFRE
//#define ITEAD_SONOFF_IFAN02 //#define ITEAD_SONOFF_IFAN02
//#define GENERIC_AG_L4 //#define GENERIC_AG_L4
//#define HOMECUBE_16A
//#define ALLTERCO_SHELLY1 //#define ALLTERCO_SHELLY1
//#define LOHAS_9W //#define LOHAS_9W
//#define YJZK_SWITCH_1CH
//#define YJZK_SWITCH_3CH
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// Features (values below are non-default values) // Features (values below are non-default values)


+ 4
- 0
code/espurna/config/device.h View File

@ -98,6 +98,8 @@ enum devices {
DEVICE_HOMECUBE_16A, DEVICE_HOMECUBE_16A,
DEVICE_ALLTERCO_SHELLY1, DEVICE_ALLTERCO_SHELLY1,
DEVICE_LOHAS_9W, DEVICE_LOHAS_9W,
DEVICE_YJZK_SWITCH_1CH,
DEVICE_YJZK_SWITCH_3CH,
DEVICE_LAST DEVICE_LAST
@ -154,7 +156,9 @@ enum devices {
defined(WION_50055) || \ defined(WION_50055) || \
defined(WORKCHOICE_ECOPLUG) || \ defined(WORKCHOICE_ECOPLUG) || \
defined(XENON_SM_PW702U) || \ defined(XENON_SM_PW702U) || \
defined(YJZK_SWITCH_1CH) || \
defined(YJZK_SWITCH_2CH) || \ defined(YJZK_SWITCH_2CH) || \
defined(YJZK_SWITCH_3CH) || \
defined(ZHILDE_EU44_W) defined(ZHILDE_EU44_W)
#undef ESPURNA_IMAGE #undef ESPURNA_IMAGE


+ 1
- 1
code/espurna/config/version.h View File

@ -1,5 +1,5 @@
#define APP_NAME "ESPURNA" #define APP_NAME "ESPURNA"
#define APP_VERSION "1.13.2c"
#define APP_VERSION "2.0.0RC1"
#define APP_AUTHOR "xose.perez@gmail.com" #define APP_AUTHOR "xose.perez@gmail.com"
#define APP_WEBSITE "http://tinkerman.cat" #define APP_WEBSITE "http://tinkerman.cat"
#define CFG_VERSION 4 #define CFG_VERSION 4

BIN
code/espurna/data/index.all.html.gz View File


+ 90
- 2
code/espurna/device.ino View File

@ -983,6 +983,28 @@ void _deviceLoad() {
setSetting("myDCKIGPIO", 15); setSetting("myDCKIGPIO", 15);
setSetting("myMapping", "0123"); setSetting("myMapping", "0123");
#elif defined(YJZK_SWITCH_1CH)
setSetting("board", DEVICE_YJZK_SWITCH_1CH);
setSetting("device", "YJZK_SWITCH_1CH");
setSetting("fw", ESPURNA_BASIC);
setSetting("btnGPIO", 0, 0);
setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
setSetting("btnRelay", 0, 0);
setSetting("btnPress", 0, BUTTON_MODE_TOGGLE);
setSetting("btnClick", 0, BUTTON_MODE_NONE);
setSetting("btnDblClick", 0, BUTTON_MODE_NONE);
setSetting("btnLngClick", 0, BUTTON_MODE_NONE);
setSetting("btnLngLngClick", 0, BUTTON_MODE_RESET);
setSetting("ledGPIO", 0, 13);
setSetting("ledLogic", 0, GPIO_LOGIC_DIRECT);
setSetting("rlyGPIO", 0, 12);
setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
#elif defined(YJZK_SWITCH_2CH) #elif defined(YJZK_SWITCH_2CH)
setSetting("board", DEVICE_YJZK_SWITCH_2CH); setSetting("board", DEVICE_YJZK_SWITCH_2CH);
@ -996,13 +1018,66 @@ void _deviceLoad() {
setSetting("btnRelay", 0, 0); setSetting("btnRelay", 0, 0);
setSetting("btnRelay", 1, 1); setSetting("btnRelay", 1, 1);
setSetting("btnPress", 0, BUTTON_MODE_TOGGLE);
setSetting("btnClick", 0, BUTTON_MODE_NONE);
setSetting("btnDblClick", 0, BUTTON_MODE_NONE);
setSetting("btnLngClick", 0, BUTTON_MODE_NONE);
setSetting("btnLngLngClick", 0, BUTTON_MODE_RESET);
setSetting("btnPress", 1, BUTTON_MODE_TOGGLE);
setSetting("btnClick", 1, BUTTON_MODE_NONE);
setSetting("btnDblClick", 1, BUTTON_MODE_NONE);
setSetting("btnLngClick", 1, BUTTON_MODE_NONE);
setSetting("btnLngLngClick", 1, BUTTON_MODE_RESET);
setSetting("ledGPIO", 0, 13);
setSetting("ledLogic", 0, GPIO_LOGIC_DIRECT);
setSetting("rlyGPIO", 0, 12);
setSetting("rlyGPIO", 1, 5);
setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
setSetting("rlyType", 1, RELAY_TYPE_NORMAL);
#elif defined(YJZK_SWITCH_3CH)
setSetting("board", DEVICE_YJZK_SWITCH_3CH);
setSetting("device", "YJZK_SWITCH_3CH");
setSetting("fw", ESPURNA_BASIC);
setSetting("btnGPIO", 0, 0);
setSetting("btnGPIO", 1, 9);
setSetting("btnGPIO", 2, 10);
setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
setSetting("btnMode", 1, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
setSetting("btnMode", 2, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH);
setSetting("btnRelay", 0, 0);
setSetting("btnRelay", 1, 1);
setSetting("btnRelay", 2, 2);
setSetting("btnPress", 0, BUTTON_MODE_TOGGLE);
setSetting("btnClick", 0, BUTTON_MODE_NONE);
setSetting("btnDblClick", 0, BUTTON_MODE_NONE);
setSetting("btnLngClick", 0, BUTTON_MODE_NONE);
setSetting("btnLngLngClick", 0, BUTTON_MODE_RESET);
setSetting("btnPress", 1, BUTTON_MODE_TOGGLE);
setSetting("btnClick", 1, BUTTON_MODE_NONE);
setSetting("btnDblClick", 1, BUTTON_MODE_NONE);
setSetting("btnLngClick", 1, BUTTON_MODE_NONE);
setSetting("btnLngLngClick", 1, BUTTON_MODE_RESET);
setSetting("btnPress", 2, BUTTON_MODE_TOGGLE);
setSetting("btnClick", 2, BUTTON_MODE_NONE);
setSetting("btnDblClick", 2, BUTTON_MODE_NONE);
setSetting("btnLngClick", 2, BUTTON_MODE_NONE);
setSetting("btnLngLngClick", 2, BUTTON_MODE_RESET);
setSetting("ledGPIO", 0, 13); setSetting("ledGPIO", 0, 13);
setSetting("ledLogic", 0, GPIO_LOGIC_DIRECT); setSetting("ledLogic", 0, GPIO_LOGIC_DIRECT);
setSetting("rlyGPIO", 0, 12); setSetting("rlyGPIO", 0, 12);
setSetting("rlyGPIO", 1, 5); setSetting("rlyGPIO", 1, 5);
setSetting("rlyGPIO", 2, 4);
setSetting("rlyType", 0, RELAY_TYPE_NORMAL); setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
setSetting("rlyType", 1, RELAY_TYPE_NORMAL); setSetting("rlyType", 1, RELAY_TYPE_NORMAL);
setSetting("rlyType", 2, RELAY_TYPE_NORMAL);
#elif defined(ITEAD_SONOFF_DUAL_R2) #elif defined(ITEAD_SONOFF_DUAL_R2)
@ -1949,8 +2024,8 @@ void _deviceLoad() {
setSetting("rlyProvider", RELAY_PROVIDER_LIGHT); setSetting("rlyProvider", RELAY_PROVIDER_LIGHT);
setSetting("rlyDummy", 1); setSetting("rlyDummy", 1);
setSetting("litChFactor", 4, 0.1); // White LEDs are way more bright in the B1
setSetting("litChFactor", 5, 0.1); // White LEDs are way more bright in the B1
setSetting("litChFactor", 4, 0.1); // White LEDs are way more bright
setSetting("litChFactor", 5, 0.1); // White LEDs are way more bright
setSetting("myModel", 1); // 3 channels per chip setSetting("myModel", 1); // 3 channels per chip
setSetting("myChips", 2); setSetting("myChips", 2);
@ -1958,6 +2033,19 @@ void _deviceLoad() {
setSetting("myDCKIGPIO", 15); setSetting("myDCKIGPIO", 15);
setSetting("myMapping", "01234"); // TODO setSetting("myMapping", "01234"); // TODO
#elif defined(ALLTERCO_SHELLY1)
setSetting("board", DEVICE_ALLTERCO_SHELLY1);
setSetting("device", "ALLTERCO_SHELLY1");
setSetting("fw", ESPURNA_BASIC);
setSetting("btnGPIO", 0, 5);
setSetting("btnMode", 0, BUTTON_SWITCH);
setSetting("btnRelay", 0, 0);
setSetting("rlyGPIO", 0, 4);
setSetting("rlyType", 0, RELAY_TYPE_NORMAL);
#endif #endif
} }


+ 3
- 2
code/espurna/ir.ino View File

@ -26,12 +26,13 @@ unsigned long _ir_last_toggle = 0;
void _irProcessCode(unsigned long code, unsigned char type) { void _irProcessCode(unsigned long code, unsigned char type) {
// Check valid code // Check valid code
unsigned long last_code = 0;
unsigned long last_time = 0;
static unsigned long last_code = 0;
static unsigned long last_time = 0;
if (code == 0xFFFFFFFF) return; if (code == 0xFFFFFFFF) return;
if (type == 0xFF) return; if (type == 0xFF) return;
if ((last_code == code) && (millis() - last_time < IR_DEBOUNCE)) return; if ((last_code == code) && (millis() - last_time < IR_DEBOUNCE)) return;
last_code = code; last_code = code;
last_time = millis();
DEBUG_MSG_P(PSTR("[IR] Received 0x%08X (%d)\n"), code, type); DEBUG_MSG_P(PSTR("[IR] Received 0x%08X (%d)\n"), code, type);
#if IR_BUTTON_SET > 0 #if IR_BUTTON_SET > 0


+ 19
- 17
code/espurna/pwm.c View File

@ -19,27 +19,29 @@
/* Set the following three defines to your needs */ /* Set the following three defines to your needs */
#ifndef SDK_PWM_PERIOD_COMPAT_MODE #ifndef SDK_PWM_PERIOD_COMPAT_MODE
#define SDK_PWM_PERIOD_COMPAT_MODE 0
#define SDK_PWM_PERIOD_COMPAT_MODE 0
#endif #endif
#ifndef PWM_MAX_CHANNELS #ifndef PWM_MAX_CHANNELS
#define PWM_MAX_CHANNELS 8
#define PWM_MAX_CHANNELS 8
#endif #endif
#define PWM_DEBUG 0
#define PWM_USE_NMI 1
#define PWM_DEBUG 0
#define PWM_USE_NMI 1
/* no user servicable parts beyond this point */ /* no user servicable parts beyond this point */
#define PWM_MAX_TICKS 0x7fffff
#define PWM_MAX_TICKS 0x7fffff
#if SDK_PWM_PERIOD_COMPAT_MODE #if SDK_PWM_PERIOD_COMPAT_MODE
#define PWM_PERIOD_TO_TICKS(x) (x * 0.2)
#define PWM_DUTY_TO_TICKS(x) (x * 5)
#define PWM_MAX_DUTY (PWM_MAX_TICKS * 0.2)
#define PWM_MAX_PERIOD (PWM_MAX_TICKS * 5)
#define PWM_PERIOD_TO_TICKS(x) (x * 0.2)
#define PWM_DUTY_TO_TICKS(x) (x * 5)
#define PWM_MAX_DUTY (PWM_MAX_TICKS * 0.2)
#define PWM_MAX_PERIOD (PWM_MAX_TICKS * 5)
#else #else
#define PWM_PERIOD_TO_TICKS(x) (x)
#define PWM_DUTY_TO_TICKS(x) (x)
#define PWM_MAX_DUTY PWM_MAX_TICKS
#define PWM_MAX_PERIOD PWM_MAX_TICKS
#define PWM_PERIOD_TO_TICKS(x) (x)
#define PWM_DUTY_TO_TICKS(x) (x)
#define PWM_MAX_DUTY PWM_MAX_TICKS
#define PWM_MAX_PERIOD PWM_MAX_TICKS
#endif #endif
#include <c_types.h> #include <c_types.h>
@ -48,8 +50,8 @@
#include "libs/pwm.h" #include "libs/pwm.h"
// from SDK hw_timer.c // from SDK hw_timer.c
#define TIMER1_DIVIDE_BY_16 0x0004
#define TIMER1_ENABLE_TIMER 0x0080
#define TIMER1_DIVIDE_BY_16 0x0004
#define TIMER1_ENABLE_TIMER 0x0080
struct pwm_phase { struct pwm_phase {
uint32_t ticks; ///< delay until next phase, in 200ns units uint32_t ticks; ///< delay until next phase, in 200ns units
@ -400,7 +402,7 @@ pwm_start(void)
void ICACHE_FLASH_ATTR void ICACHE_FLASH_ATTR
pwm_set_duty(uint32_t duty, uint8_t channel) pwm_set_duty(uint32_t duty, uint8_t channel)
{ {
if (channel > PWM_MAX_CHANNELS)
if (channel >= PWM_MAX_CHANNELS)
return; return;
if (duty > PWM_MAX_DUTY) if (duty > PWM_MAX_DUTY)
@ -412,7 +414,7 @@ pwm_set_duty(uint32_t duty, uint8_t channel)
uint32_t ICACHE_FLASH_ATTR uint32_t ICACHE_FLASH_ATTR
pwm_get_duty(uint8_t channel) pwm_get_duty(uint8_t channel)
{ {
if (channel > PWM_MAX_CHANNELS)
if (channel >= PWM_MAX_CHANNELS)
return 0; return 0;
return pwm_duty[channel]; return pwm_duty[channel];
} }


+ 10
- 2
code/espurna/sensors/DHTSensor.h View File

@ -15,6 +15,7 @@
#define DHT_MIN_INTERVAL 2000 #define DHT_MIN_INTERVAL 2000
#define DHT_CHIP_DHT11 11 #define DHT_CHIP_DHT11 11
#define DHT_CHIP_DHT12 12
#define DHT_CHIP_DHT22 22 #define DHT_CHIP_DHT22 22
#define DHT_CHIP_DHT21 21 #define DHT_CHIP_DHT21 21
#define DHT_CHIP_AM2301 21 #define DHT_CHIP_AM2301 21
@ -145,7 +146,7 @@ class DHTSensor : public BaseSensor {
pinMode(_gpio, OUTPUT); pinMode(_gpio, OUTPUT);
noInterrupts(); noInterrupts();
digitalWrite(_gpio, LOW); digitalWrite(_gpio, LOW);
if (_type == DHT_CHIP_DHT11) {
if ((_type == DHT_CHIP_DHT11) || (_type == DHT_CHIP_DHT12)) {
nice_delay(20); nice_delay(20);
} else { } else {
delayMicroseconds(500); delayMicroseconds(500);
@ -201,6 +202,9 @@ class DHTSensor : public BaseSensor {
// Get humidity from Data[0] and Data[1] // Get humidity from Data[0] and Data[1]
if (_type == DHT_CHIP_DHT11) { if (_type == DHT_CHIP_DHT11) {
_humidity = dhtData[0]; _humidity = dhtData[0];
} else if (_type == DHT_CHIP_DHT12) {
_humidity = dhtData[0];
_humidity += dhtData[1] * 0.1;
} else { } else {
_humidity = dhtData[0] * 256 + dhtData[1]; _humidity = dhtData[0] * 256 + dhtData[1];
_humidity /= 10; _humidity /= 10;
@ -209,6 +213,10 @@ class DHTSensor : public BaseSensor {
// Get temp from Data[2] and Data[3] // Get temp from Data[2] and Data[3]
if (_type == DHT_CHIP_DHT11) { if (_type == DHT_CHIP_DHT11) {
_temperature = dhtData[2]; _temperature = dhtData[2];
} else if (_type == DHT_CHIP_DHT12) {
_temperature = (dhtData[2] & 0x7F);
_temperature += dhtData[3] * 0.1;
if (dhtData[2] & 0x80) _temperature *= -1;
} else { } else {
_temperature = (dhtData[2] & 0x7F) * 256 + dhtData[3]; _temperature = (dhtData[2] & 0x7F) * 256 + dhtData[3];
_temperature /= 10; _temperature /= 10;
@ -238,7 +246,7 @@ class DHTSensor : public BaseSensor {
unsigned char _errors = 0; unsigned char _errors = 0;
double _temperature = 0; double _temperature = 0;
unsigned int _humidity = 0;
double _humidity = 0;
}; };


+ 3097
- 3053
code/espurna/static/index.all.html.gz.h
File diff suppressed because it is too large
View File


+ 0
- 4
code/espurna/utils.ino View File

@ -71,10 +71,6 @@ String getCoreRevision() {
#endif #endif
} }
unsigned long maxSketchSpace() {
return (ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000;
}
// WTF // WTF
// Calling ESP.getFreeHeap() is making the system crash on a specific // Calling ESP.getFreeHeap() is making the system crash on a specific
// AiLight bulb, but anywhere else... // AiLight bulb, but anywhere else...


+ 0
- 4
code/extra_scripts.py View File

@ -4,11 +4,7 @@ from __future__ import print_function
import os import os
import sys import sys
from subprocess import call from subprocess import call
import click import click
from platformio import util
import distutils.spawn
Import("env", "projenv") Import("env", "projenv")


+ 3
- 3
code/gulpfile.js View File

@ -77,8 +77,8 @@ var toHeader = function(name, debug) {
output += '#define ' + safename + '_len ' + source.contents.length + '\n'; output += '#define ' + safename + '_len ' + source.contents.length + '\n';
output += 'const uint8_t ' + safename + '[] PROGMEM = {'; output += 'const uint8_t ' + safename + '[] PROGMEM = {';
for (var i=0; i<source.contents.length; i++) { for (var i=0; i<source.contents.length; i++) {
if (i > 0) output += ',';
if (0 === (i % 20)) output += '\n';
if (i > 0) { output += ','; }
if (0 === (i % 20)) { output += '\n'; }
output += '0x' + ('00' + source.contents[i].toString(16)).slice(-2); output += '0x' + ('00' + source.contents[i].toString(16)).slice(-2);
} }
output += '\n};'; output += '\n};';
@ -120,7 +120,7 @@ var buildWebUI = function(module) {
if ('all' === module) { if ('all' === module) {
modules['light'] = true; modules['light'] = true;
modules['sensor'] = true; modules['sensor'] = true;
modules['rfbridge'] = false; // we will never be adding this except when building RFBRIDGE
modules['rfbridge'] = true;
modules['rfm69'] = false; // we will never be adding this except when building RFM69GW modules['rfm69'] = false; // we will never be adding this except when building RFM69GW
} else if ('small' !== module) { } else if ('small' !== module) {
modules[module] = true; modules[module] = true;


+ 8
- 2
code/ota.py View File

@ -39,6 +39,8 @@ def on_service_state_change(zeroconf, service_type, name, state_change):
Callback that adds discovered devices to "devices" list Callback that adds discovered devices to "devices" list
""" """
global discover_last
if state_change is ServiceStateChange.Added: if state_change is ServiceStateChange.Added:
discover_last = time.time() discover_last = time.time()
info = zeroconf.get_service_info(service_type, name) info = zeroconf.get_service_info(service_type, name)
@ -60,6 +62,11 @@ def on_service_state_change(zeroconf, service_type, name, state_change):
for key, item in info.properties.items(): for key, item in info.properties.items():
device[key.decode('UTF-8')] = item.decode('UTF-8'); device[key.decode('UTF-8')] = item.decode('UTF-8');
# rename fields (needed for sorting by name)
device['app'] = device['app_name']
device['device'] = device['target_board']
device['version'] = device['app_version']
devices.append(device) devices.append(device)
@ -141,7 +148,6 @@ def get_board_by_mac(mac):
""" """
Returns the required data to flash a given board Returns the required data to flash a given board
""" """
hostname = hostname.lower()
for device in devices: for device in devices:
if device.get('mac', '').lower() == mac: if device.get('mac', '').lower() == mac:
board = {} board = {}
@ -209,7 +215,7 @@ def input_board():
# Choose board size of none before # Choose board size of none before
if board.get('size', 0) == 0: if board.get('size', 0) == 0:
try: try:
board['size'] = int(input("Board memory size (1 for 1M, 4 for 4M): "))
board['size'] = int(input("Board memory size (1 for 1M, 2 for 2M, 4 for 4M): "))
except ValueError: except ValueError:
print("Wrong memory size") print("Wrong memory size")
return None return None


+ 81
- 5
code/platformio.ini View File

@ -41,6 +41,7 @@ debug_flags = -DDEBUG_ESP_CORE -DDEBUG_ESP_SSL -DDEBUG_ESP_WIFI -DDEBUG_ESP_HTTP
build_flags = -g -w -DMQTT_MAX_PACKET_SIZE=400 -DNO_GLOBAL_EEPROM ${sysenv.ESPURNA_FLAGS} -DPIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH build_flags = -g -w -DMQTT_MAX_PACKET_SIZE=400 -DNO_GLOBAL_EEPROM ${sysenv.ESPURNA_FLAGS} -DPIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH
build_flags_512k = ${common.build_flags} -Wl,-Teagle.flash.512k0m1s.ld build_flags_512k = ${common.build_flags} -Wl,-Teagle.flash.512k0m1s.ld
build_flags_1m0m = ${common.build_flags} -Wl,-Teagle.flash.1m0m1s.ld build_flags_1m0m = ${common.build_flags} -Wl,-Teagle.flash.1m0m1s.ld
build_flags_2m1m = ${common.build_flags} -Wl,-Teagle.flash.2m1m4s.ld
build_flags_4m1m = ${common.build_flags} -Wl,-Teagle.flash.4m1m4s.ld build_flags_4m1m = ${common.build_flags} -Wl,-Teagle.flash.4m1m4s.ld
build_flags_4m3m = ${common.build_flags} -Wl,-Teagle.flash.4m3m4s.ld build_flags_4m3m = ${common.build_flags} -Wl,-Teagle.flash.4m3m4s.ld
@ -55,6 +56,7 @@ upload_flags = --auth="${sysenv.ESPURNA_AUTH}"
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
framework = arduino framework = arduino
board_1m = esp01_1m board_1m = esp01_1m
board_2m = esp_wroom_02
board_4m = esp12e board_4m = esp12e
flash_mode = dout flash_mode = dout
monitor_speed = 115200 monitor_speed = 115200
@ -76,7 +78,7 @@ lib_deps =
https://github.com/plerup/espsoftwareserial#3.4.1 https://github.com/plerup/espsoftwareserial#3.4.1
https://github.com/me-no-dev/ESPAsyncTCP#55cd520 https://github.com/me-no-dev/ESPAsyncTCP#55cd520
https://github.com/me-no-dev/ESPAsyncWebServer#05306e4 https://github.com/me-no-dev/ESPAsyncWebServer#05306e4
https://bitbucket.org/xoseperez/fauxmoesp.git#2.4.2
https://bitbucket.org/xoseperez/fauxmoesp.git#3.0.0
https://github.com/xoseperez/hlw8012.git#1.1.0 https://github.com/xoseperez/hlw8012.git#1.1.0
https://github.com/markszabo/IRremoteESP8266#v2.2.0 https://github.com/markszabo/IRremoteESP8266#v2.2.0
https://github.com/xoseperez/justwifi.git#2.0.1 https://github.com/xoseperez/justwifi.git#2.0.1
@ -108,6 +110,17 @@ build_flags = ${common.build_flags_1m0m} -DESPURNA_CORE
monitor_speed = ${common.monitor_speed} monitor_speed = ${common.monitor_speed}
extra_scripts = ${common.extra_scripts} extra_scripts = ${common.extra_scripts}
[env:espurna-core-2MB]
platform = ${common.platform}
framework = ${common.framework}
board = ${common.board_2m}
board_build.flash_mode = ${common.flash_mode}
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags_2m1m} -DESPURNA_CORE
monitor_speed = ${common.monitor_speed}
extra_scripts = ${common.extra_scripts}
[env:espurna-core-4MB] [env:espurna-core-4MB]
platform = ${common.platform} platform = ${common.platform}
framework = ${common.framework} framework = ${common.framework}
@ -136,6 +149,19 @@ upload_port = ${common.upload_port}
upload_flags = ${common.upload_flags} upload_flags = ${common.upload_flags}
extra_scripts = ${common.extra_scripts} extra_scripts = ${common.extra_scripts}
[env:esp8266-2m-ota]
platform = ${common.platform}
framework = ${common.framework}
board = ${common.board_2m}
board_build.flash_mode = ${common.flash_mode}
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags_2m1m} -D${sysenv.ESPURNA_BOARD}
upload_speed = ${common.upload_speed}
upload_port = ${common.upload_port}
upload_flags = ${common.upload_flags}
extra_scripts = ${common.extra_scripts}
[env:esp8266-4m-ota] [env:esp8266-4m-ota]
platform = ${common.platform} platform = ${common.platform}
framework = ${common.framework} framework = ${common.framework}
@ -1689,6 +1715,31 @@ upload_flags = ${common.upload_flags}
monitor_speed = ${common.monitor_speed} monitor_speed = ${common.monitor_speed}
extra_scripts = ${common.extra_scripts} extra_scripts = ${common.extra_scripts}
[env:yjzk-switch-1ch]
platform = ${common.platform}
framework = ${common.framework}
board = ${common.board_1m}
board_build.flash_mode = ${common.flash_mode}
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags_1m0m} -DYJZK_SWITCH_1CH
monitor_speed = ${common.monitor_speed}
extra_scripts = ${common.extra_scripts}
[env:yjzk-switch-1ch-ota]
platform = ${common.platform}
framework = ${common.framework}
board = ${common.board_1m}
board_build.flash_mode = ${common.flash_mode}
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags_1m0m} -DYJZK_SWITCH_1CH
upload_speed = ${common.upload_speed}
upload_port = ${common.upload_port}
upload_flags = ${common.upload_flags}
monitor_speed = ${common.monitor_speed}
extra_scripts = ${common.extra_scripts}
[env:yjzk-switch-2ch] [env:yjzk-switch-2ch]
platform = ${common.platform} platform = ${common.platform}
framework = ${common.framework} framework = ${common.framework}
@ -1714,6 +1765,31 @@ upload_flags = ${common.upload_flags}
monitor_speed = ${common.monitor_speed} monitor_speed = ${common.monitor_speed}
extra_scripts = ${common.extra_scripts} extra_scripts = ${common.extra_scripts}
[env:yjzk-switch-3ch]
platform = ${common.platform}
framework = ${common.framework}
board = ${common.board_1m}
board_build.flash_mode = ${common.flash_mode}
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags_1m0m} -DYJZK_SWITCH_3CH
monitor_speed = ${common.monitor_speed}
extra_scripts = ${common.extra_scripts}
[env:yjzk-switch-3ch-ota]
platform = ${common.platform}
framework = ${common.framework}
board = ${common.board_1m}
board_build.flash_mode = ${common.flash_mode}
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags_1m0m} -DYJZK_SWITCH_3CH
upload_speed = ${common.upload_speed}
upload_port = ${common.upload_port}
upload_flags = ${common.upload_flags}
monitor_speed = ${common.monitor_speed}
extra_scripts = ${common.extra_scripts}
[env:generic-8ch] [env:generic-8ch]
platform = ${common.platform} platform = ${common.platform}
framework = ${common.framework} framework = ${common.framework}
@ -2462,25 +2538,25 @@ upload_flags = ${common.upload_flags}
monitor_speed = ${common.monitor_speed} monitor_speed = ${common.monitor_speed}
extra_scripts = ${common.extra_scripts} extra_scripts = ${common.extra_scripts}
[env:allterco-sheely1]
[env:allterco-shelly1]
platform = ${common.platform} platform = ${common.platform}
framework = ${common.framework} framework = ${common.framework}
board = ${common.board_1m} board = ${common.board_1m}
board_build.flash_mode = ${common.flash_mode} board_build.flash_mode = ${common.flash_mode}
lib_deps = ${common.lib_deps} lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore} lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags_1m0m} -DALLTERCO_SHELLY1
build_flags = ${common.build_flags_2m1m} -DALLTERCO_SHELLY1
monitor_speed = ${common.monitor_speed} monitor_speed = ${common.monitor_speed}
extra_scripts = ${common.extra_scripts} extra_scripts = ${common.extra_scripts}
[env:allterco-sheely1-ota]
[env:allterco-shelly1-ota]
platform = ${common.platform} platform = ${common.platform}
framework = ${common.framework} framework = ${common.framework}
board = ${common.board_1m} board = ${common.board_1m}
board_build.flash_mode = ${common.flash_mode} board_build.flash_mode = ${common.flash_mode}
lib_deps = ${common.lib_deps} lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore} lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags_1m0m} -DALLTERCO_SHELLY1
build_flags = ${common.build_flags_2m1m} -DALLTERCO_SHELLY1
upload_speed = ${common.upload_speed} upload_speed = ${common.upload_speed}
upload_port = ${common.upload_port} upload_port = ${common.upload_port}
upload_flags = ${common.upload_flags} upload_flags = ${common.upload_flags}


BIN
images/devices/ag-l4.jpg View File

Before After
Width: 400  |  Height: 400  |  Size: 81 KiB

BIN
images/devices/allterco-shelly1.jpg View File

Before After
Width: 400  |  Height: 400  |  Size: 42 KiB

BIN
images/devices/homecube-16a.jpg View File

Before After
Width: 400  |  Height: 400  |  Size: 19 KiB

BIN
images/devices/lohas-9w.jpg View File

Before After
Width: 400  |  Height: 400  |  Size: 14 KiB

Loading…
Cancel
Save