Commit Graph

2768 Commits

Author SHA1 Message Date
Esteban Zapata Rojas
d60ff79eda hardware: Add support for HUGOAI smart socket plug. (#2243)
* hardware: Add support for HUGOAI smart socket plug.

* Update code/platformio.ini

Co-authored-by: pezinek <pezinek@gmail.com>

Co-authored-by: Max Prokhorov <prokhorov.max@outlook.com>
Co-authored-by: pezinek <pezinek@gmail.com>
2020-05-12 23:06:57 +03:00
Max Prokhorov
7a5f580915 sns: fix unintended switch case fallthrough (#2249) 2020-05-12 23:06:35 +03:00
Max Prokhorov
e44bb0ecbc ws: directly iterate over internal callbacks array (#2248)
tnx to @RDobrinov
https://gist.github.com/RDobrinov/9e739fd77990d0a77fc1b867176bf48c
2020-05-12 23:03:21 +03:00
Max Prokhorov
025e8c82ab Load ratios after boot + show pwr defaults with get (#2241)
* emon: configure ratios without reboot

* settings: serialize() support

* debug: use vsnprintf from newlib, not from sdk

* settings/experimental: show defaults via `get`

* emon: override base methods, fix defaults

* sensor/emon: expose internal index calculation

- refactor configuration to use the correct index when accessing indexed
  sensor methods. store index value on magnitude, refactor loops to
  accomodate this new functionality
- rename slot(index) -> description(index), since we use 'slot' as
  numeric value
2020-05-12 21:17:01 +03:00
Max Prokhorov
a2a44c28d4 Update IRremoteESP8266 to 2.7.4 (#2182)
* Update IRremoteESP8266 to 2.7.4

Fix version specifier, use PIO registry instead of git
Need this for -DALLOW_DELAY_CALLS=false

* Update platformio.ini

https://platformio.org/lib/show/1089/IRremoteESP8266/installation
2020-05-12 21:16:33 +03:00
Maxim Prokhorov
31641aeffa emon: default indexed methods to method without argument 2020-05-02 00:44:54 +03:00
Maxim Prokhorov
96347b7244 hlw8012: set ratios in begin(), after resistors are configured 2020-05-02 00:44:54 +03:00
Max Prokhorov
e60c561f70 Actually apply button pulldown
Properly follow ternary else() chain, help out by pre-pending if()
Resolve #2239, thanks to @sigmafx
2020-05-01 21:54:53 +03:00
Albert Weterings
ff2718e8ca KingArt WiFi Curtain Switch (#2063)
This will add support for the KingArt Wifi Curtain Switch. There are no buttons in the web interface as I could not figure out how to create them (any help on that is welcome).

For now the switch can be controlled over MQTT:
"{hostname}/curtain/set"
"{hostname}/curtain"
2020-05-01 12:45:41 +03:00
Maxim Prokhorov
01f5afff80 rfbridge: properly check hex<->byte functions results 2020-05-01 10:19:26 +03:00
Maxim Prokhorov
455b5b1abc Add missing headers 2020-05-01 10:19:26 +03:00
Maxim Prokhorov
50163fc051 Add line hint to the single source file
c/p from the InoToCpp converter that uses scons file node path
while we write binary data as utf-8 (and assume it is utf-8!),
we only ever need this in CI and source is always relative.
with luck, this is on the safe side.
2020-05-01 10:19:26 +03:00
Esteban Zapata Rojas
9d2534f641 hardware: Add support for Aoycocr X5P Plug. (#2235)
* hardware: Add support for Aoycocr X5P Plug.

This change allow espurna to control Aoycocr X5P Plug devices, which has
the same behaviour as the GOSUND WP3 but using different GPIO pins for
relay, button and leds.

* Update platformio.ini

Co-authored-by: Max Prokhorov <prokhorov.max@outlook.com>
2020-04-30 22:09:11 +03:00
Max Prokhorov
fcba0ce0fb Fix rfbridge function names and order (#2236)
* rfbridge: fix names and ordering

* build rfbridge
2020-04-30 22:08:44 +03:00
Max Prokhorov
4d39c5fdb6 Add extraSetup() signature
main.cpp setup() needs to know about it
2020-04-30 14:26:26 +03:00
Max Prokhorov
edb23dbfc4 Convert .ino -> .cpp (#2228)
- general conversion from .ino modules into a separate .cpp files
- clean-up internal headers, place libraries into .h. guard .cpp with _SUPPORT flags 
- fix some instances of shared variables instead of public methods
- tweak build system to still build a single source file via os environment variable ESPURNA_BUILD_SINGLE_SOURCE
2020-04-30 13:55:07 +03:00
Max Prokhorov
732e84c45e Various sensor fixes (#2230)
* hlw8012: load hardware-specific ratios
* hlw8012: read energy in pre() callback
* dcz: nvalue should be integer
* sns: fix pressure constrain
* sns: load ratios based on index too
* sns: per-magnitude corrections (still limited by type)
* sns: attach units to index
2020-04-28 07:12:42 +03:00
Alexander
49995d92d1 Add HDC1080, fix ADC_MODE_VALUE use in preprocessor (#2227)
* ADC_VCC is not macro

* In esp.h ADC_VCC and ADC_TOUT is not macro, so define macro.

* ADC_VCC and ADC_TOUT fixes in utils.ino and sensors.h

* Adding support for I2C temperature and humidity sensor HDC1080 / 831R

* Added HDC1080 to test\build\sensor.h and arduino.h

* added brackets

* Revert ADC_MODE_VALUE to initial values

* Eof newline

* Eof newline

Co-authored-by: Max Prokhorov <prokhorov.max@outlook.com>
2020-04-25 07:46:37 +03:00
Maxim Prokhorov
2dcf1b2bd8 cfg: move DEVICE and MANUFACTURER to functions
Avoids useless logs like this one:
https://travis-ci.com/github/mcspr/espurna-nightly-builder/jobs/316891026#L449
2020-04-08 23:28:43 +03:00
Maxim Prokhorov
492a35926f ci: rework build.sh & release.sh generator
- don't depend on TRAVIS environment variables
- depend on CI flag to add release variables
- chmod +x
2020-04-08 23:28:43 +03:00
Max Prokhorov
945652f806 btn: key0 should override key
https://github.com/xoseperez/espurna/pull/1772#issuecomment-609847420
> Without the patch btnRepDel overrides every btnRepDel0, btnRepDel1 etc., btnRepDel0 read second, then hard-coded value.
With the patch btnRepDel0 is read first, then btnRepDel, then hard-coded value.

Indexed key can only be set via settings upload or in terminal, WebUI can change only the global override setting. Allow more 'specific' key to override global setting.
2020-04-08 02:41:09 +03:00
Max Prokhorov
92bdf211eb Update platformio.ini comments
Clarify flash size settings, fix old comment regarding build_flags
2020-04-08 02:33:26 +03:00
Max Prokhorov
b500273029 sns: add SI1145 sensor (#2216)
Co-authored-by: Joop Hilverink <33230021+HilverinkJ@users.noreply.github.com>
2020-04-08 01:48:45 +03:00
Max Prokhorov
5de6330890 dcz: add workaround for pressure sensors (#2215)
- Domoticz only accepts svalue <pressure>;<forecast>,
  failing to display anything otherwise.
  We don't have any forecast calculation (yet?), simply send dummy value.
- Move Domoticz code outside of sensor.ino
2020-04-08 01:35:33 +03:00
Max Prokhorov
cae50fa544 sensor/emon: refactoring (#2213)
- Update sensor classes to support a generic way to store energy values
- Update sensor conversion code to deal with units and not magnitudes
- Add magnitude<->unit for sensors, generic way of defining used unit. Convert from sensor magnitude unit to the one used for display.
- Reset energy value based on index through external means (MQTT, HTTP)
- Rework energy timestamping, update webui with 'last saved' value

While this solves the energy conversion issues and we are finally seeing the real value, what I don't really like:
- KilowattHour and WattHour are separate enum tags, thus sort-of are different types altogether
- Conversion code in Energy object should probably use some generic 'ratio' calculation? (https://en.cppreference.com/w/cpp/numeric/ratio/ratio)
- We are still using runtime checks to do calculations and depend that sensor outputs only one specific value type.

Consider this a fix for energy display / storage and preliminary work on sensor.ino
Further sensor refactoring... soon.
2020-04-08 00:37:26 +03:00
Max Prokhorov
49b6d351d9 PIO/hardware.h: Update naming (#2214)
* update platformio.ini comments
* espurna-base -> espurna-core-webui
* esp8266-<flavour>-<size>-base -> esp8266-<size>-<flavour>-base
* clean-up ESPURNA_CORE detection, use boards function
2020-04-07 21:48:43 +03:00
Max Prokhorov
db50be91bc PIO: fix env definitions (again) (#2212)
* base envs

* CI: speed up release process (since we still want some .bin files)

* fixup! CI: speed up release process (since we still want some .bin files)

* release dry run

* fixup! release dry run

* adjust

* fix .bin name

* it works

* minor cleanup for current git

* use pio suggestion about ldscript, reduce build_flags impact

* fix linker

* parse ${vars} instead of ignoring them

* add filtering and override file (sneak peak into tasmota's pio config)

* don't generate secure client (for now)

* formatting

* codacy
2020-04-07 21:20:32 +03:00
ziggurat29
e2e0409c59 correct Gosund WP3 LED documentation and provide reasonable default actions (#2200)
* correct Gosund WP3 led color documentation; provide reasonable default actions for button and the two LEDs

* reverse red/blue led roles, as requested, to be consistent with other existing products

Co-authored-by: ziggurat29 <xxx@yyy.zzz>
2020-04-02 02:06:19 +03:00
Max Prokhorov
83339605aa webui: ledGPIO is a list (#2202) 2020-03-30 13:41:11 +03:00
ziggurat29
387d4cea58 Board definition for the Gosund WP3 smart socket (#2191)
Co-authored-by: ziggurat29 <xxx@yyy.zzz>
2020-03-24 22:34:14 +03:00
Max Prokhorov
a71f233caa Remove OTA from ESP01 build
https://github.com/xoseperez/espurna/pull/2185#issuecomment-601198322
-11KiB
2020-03-20 21:38:03 +03:00
Max Prokhorov
43c2c41cba mqtt(async): buffer some data (#2181)
* mqtt: enum state

* mqtt: async client buffer with MQTT_MAX_PACKET_SIZE

* mqtt: rework debug messages

* mqtt: MQTT_BUFFER_MAX_SIZE

* mqtt/test: debug log for async callback

* mqtt/test: don't log things we don't handle

* button: fix typo
2020-03-20 21:07:02 +03:00
ziggurat29
7496606140 Example for Generic ESP01 boards with 512KiB flash (#2185)
Co-authored-by: ziggurat29 <xxx@yyy.zzz>
2020-03-20 21:06:12 +03:00
Max Prokhorov
917ce8de83 Optional Web(UI) OTA (#2190)
* web: optional OTA support

* add prototype

* hide under websupport
2020-03-20 21:05:04 +03:00
Maxim Prokhorov
032f921fc4 btn: store actions as uint8_t instead of uint16_t 2020-03-14 01:20:32 +03:00
Maxim Prokhorov
2172bc6cb1 btn: rename pin status / state -> value 2020-03-14 01:20:32 +03:00
Maxim Prokhorov
b289c77021 cfg: clean-up hardware.h 2020-03-13 09:28:15 +03:00
Maxim Prokhorov
ee7356b91a relay: clean-up for ota .bin 2020-03-13 09:28:15 +03:00
Maxim Prokhorov
1f5b22ebcf ir: fix syntax issue 2020-03-13 09:28:15 +03:00
Max Prokhorov
3243dafb61 cfg: check for led and button GPIO settings (#2177)
In case board configuration is empty, loop should try to check at least once
2020-03-13 07:15:07 +03:00
Max Prokhorov
80825590a5 LED Updates (#2170)
* support GPIO setting in WebUI
* experimental led pattern support
* support loading settings in setup() (not yet fully working)
2020-03-13 07:01:14 +03:00
Max Prokhorov
bdedb2b7ae wifi: unconditionally erase all settings after fixed index (#2175) 2020-03-13 04:43:54 +03:00
Max Prokhorov
f2ed94f230 cfg: update migrate configuration (#2176) 2020-03-13 04:43:35 +03:00
Max Prokhorov
ba3e6267e6 Button pin provider & runtime settings (#2162)
* wip

* cleanup buttons-through-serial code, remove hw mention from button module

* remove wip

* implement mqtt settings

* fixup struct members, dual no longer allocates debouncer

* add missing debounceevent lib

* fix missing event_handler, update names

* fix namespace

* drop lib

* fix int<->bool comparison

* Move gpio16 handling from DigitalPin to EventHandler

* Cleanup debounceevent headers

* Don't expect system headers to be included

* re 70b54c489f - no allocation, for real

* Adjust settings names

* dont retain by default

* unused

* typo

* Fix length type (ref 6017ad9474)

* Move pin class outside of debounce lib, lowercase ns

* move event handling inside of button_t

* refactor config. ..._MODE -> _CONFIG, ..._MODE_... -> ..._ACTION_...

* fix test

* naming

* move indexed value to header

* refactor actions into direct opts

* fix webui, fix buttons not respecting old user setting

* change button config format from bitmask to a struct, adjust settings conversion

* proxy some more header defautls, fix web kv

* gpiopin

* adjust webui func to support every setting

* clarify single-return event->string

* fix dual setting

* fix dual packet condition, de-duplicate funcs

* fix bogus warning
2020-03-13 04:42:40 +03:00
Rui Caridade
ae232c9381 Add support for read PIO-A of DS2406 (#2174)
* Add support for read PIO-A of DS2406

* Verify reset() reseult
2020-03-12 06:03:46 +03:00
irmishappy
c02a981b1c Apparent, reactive power measurement unit corrections (#2161)
* Update sensor.ino

Apparent, reactive power measurement unit corrections.

* Update sensor.ino
2020-03-12 06:03:17 +03:00
DmitryBlinov
373dd27d60 Fixes and updates for thermostat and display (#2173)
* Fixes and updates for thermostat and display:

- Switch to original esp8266-oled-ssd1306 library
- Fixes and updates for thermostat and display
- Add display switching off after interval
- If THERMOSTAT_DISPLAY_SUPPORT enabled, then one click enable display, long click switch relay. This functionality also depend on fix for long click. See pull request https://github.com/xoseperez/espurna/pull/2172

* Move buttons definitions for display to dependencies.h

* Pin ThingPulse/esp8266-oled-ssd1306#3398c97
2020-03-08 18:15:27 +03:00
DmitryBlinov
6017ad9474 Fix for long click (#2172)
With uint8_t length function _buttonMapReleased never returned BUTTON_EVENT_LNGCLICK. BUTTON_EVENT_CLICK returned instesd. I verified that with uint16_t length it returns BUTTON_EVENT_LNGCLICK when correspondent delay passed.
2020-03-08 02:31:16 +03:00
julianwb
8f7d77b2a1 Config for Teckin SP23 & Maxcio W-UK007S (#2157) 2020-02-18 22:23:52 +03:00
Max Prokhorov
8f4f1beb54 mqtt+api: move action handler (#2158) 2020-02-18 22:23:08 +03:00