Commit Graph

2909 Commits

Author SHA1 Message Date
Maxim Prokhorov
a62d1cdd13 pio: -latest-base -> -base for envs
Already using the "latest" stable release, no need to split things (at least for now)
2020-11-16 03:25:19 +03:00
Maxim Prokhorov
b24b0a2369 pio: fix git builds & bump current platform
- platform == platform_latest
- mcspr/toolchain-xtensa via https://github.com/platformio/platformio-core/issues/3612

Yet, this does not avoid useless warnings that platform does
not specify platformio/* prefix in the package spec :(

It should be available in the next espressif8266 version:
0859336019
2020-11-16 03:16:09 +03:00
Alex. Tircovnicu
289c8cb49c hardware: add support for Gosund P1 Power Strip (#2391) 2020-11-02 22:14:52 +03:00
aL1aL7
f6582ecd18 alexa: fix device discovery / state callback (#2388)
alexa device discovery/state calls use URL of type
/api/hash_id_key_whatever/lights

This is blocked when API is disabled and fails
also when http API is enabled because no apikey is
sent by amazon calls

Don't try to use the http api for alexa calls.
Responses for alexa are done by fauxmoesp lib,
so there's no need for the http api call.
2020-10-28 22:40:56 +03:00
Nicolas Gilles
85969e4945 hardware: add support for Benexmart GU5.3 RGBWW light (#2381)
* Add support for Benexmart GU5.3 RGBWW light

* Update arduino.h

Co-authored-by: Max Prokhorov <prokhorov.max@outlook.com>
2020-10-15 20:26:12 +03:00
tom-kaltofen
801e22a034 hardware: add support for LSC E27 10W white bulb (#2375)
* Add support for LSC E27 10W white bulb

* Add OTA config for LSC E27 10W white bulb
Add LSC E27 10W white bulb to arduino.h
2020-10-15 19:56:39 +03:00
Max Prokhorov
7a64a4a6bf btn: generate pressed & released events from switch changes (#2379)
- Add ::Released button event to be used specifically with switches, opposite of ::Pressed
- Always use default state for switches instead of ignoring it and using current pin reading as value. This allows us to boot with the switch held in the opposite state and trigger the correct event immediately
(meaning, switches now depend on the BUTTON_DEFAULT_HIGH presence to detect the default position)
- BREAKING: Fixup hardware.h. Any custom board needs manual changes.
- BREAKING: Rework MQTT button messages to send text from debug messages instead of numeric code
2020-10-15 19:55:23 +03:00
Maxim Prokhorov
aebefdf941 ntp: always use abs(offset), minus is used for positive values 2020-09-30 12:21:28 +03:00
Maxim Prokhorov
57e059a684 ntp: fix gcc-4.8.2 auto var { ... } becoming initializer_list
gcc-10.2 in the current git correctly deduces the expression :(
only tested this with the new gcc, fix the current release build
2020-09-30 11:51:06 +03:00
Maxim Prokhorov
fd9f930e71 ntp: use the actual legacy default values 2020-09-30 11:48:06 +03:00
Maxim Prokhorov
aec13cef63 ntp: clean-up
resolve #2327, #2220

- remove legacy support in the webui
- format datetime strings on the device, use NTP panel to display them both
- migrate from the old ntpOffset + ntpDST + ntpRegion to ntpTZ
2020-09-30 11:41:18 +03:00
Maxim Prokhorov
63b6f46752 Fix superfluous whitespaces and line endings
resolve #2310
2020-09-30 10:14:25 +03:00
Maxim Prokhorov
1f1d6a99d2 sns: always try to load magnitude units from settings
also, drop special builds flags in favour of sane defaults
2020-09-30 10:00:44 +03:00
Maxim Prokhorov
b0bb384bcd sns/event: event is a boolean value 2020-09-30 10:00:39 +03:00
Maxim Prokhorov
735e5c0ec2 sns/event: change counter variable only in the isr
ensure the only operation from main loop() is load
since isr handles incrementing the counter, resulting value is calculated as
offset between the current and the previous reading (always positive)
2020-09-30 10:00:38 +03:00
Alex. Tircovnicu
e859f2bbf7 hw: add support for Gosund SP111 (hardware version 1.1 16A) (#2369) 2020-09-27 05:03:32 +03:00
Max Prokhorov
0586f5d4cc ota: detect Tasmota magic numbers when booting (#2370)
- inject dummy data sequence that is expected to hold current version info
- check rtcmem markers and purge settings, since we don't want accidentally reading something as a kv
- sometimes we cannot boot b/c of certain SDK params, purge last 16KiB as well

ref. `SetOption78 1`
https://tasmota.github.io/docs/Commands/#setoptions

The original idea from Esphome:
0e59243b83/esphome/core/esphal.cpp (L275-L287)
Does not seem to be working atm. Will need to re-check with the esphome builder, c/p did not work and I tried building with gcc-10

Specific things we want to do is to have 'version' byte between 2 'marker' bytes:
217addc2bb/tasmota/settings.ino (L218-L262)       0dfa38df89/tasmota/i18n.h (L780-L782)
2020-09-27 05:01:08 +03:00
Maxim Prokhorov
1b66460638 sns: be more explicit about the copy vs. move 2020-09-27 02:56:12 +03:00
Maxim Prokhorov
723636ae21 sns/event: using cheaper isr calls, lock gpio isr when reading
Optimize isr handler once more by removing gpio -> index conversion at runtime

Drop atomics for now, since we can also make the whole operation atomic
by locking GPIO interrupts while reading and setting the counter value
And we don't have another thread / core to worry about
2020-09-27 01:50:37 +03:00
Maxim Prokhorov
e84fa98941 sns/event: only load the counter value once per reading
amend 8252f2ae18
note that platform does not implement either fetch_add or exchange

clean-up ordering once again
2020-09-26 15:42:47 +03:00
Nicolas Gilles
ca9b2fbb69 add missing lights #include for rpn rules (#2367) 2020-09-26 10:59:12 +03:00
Maxim Prokhorov
139b31287c sns: fix ci default.h overriding values in sensor.h 2020-09-26 10:57:25 +03:00
Maxim Prokhorov
8252f2ae18 sns: explicitly load before storing new counter value
resolve #2368

- Fixes "undefined reference to `__atomic_fetch_add_4'"
  Notably, std::atomic_fetch_add(&counter, 1) would also trigger this.
  std::atomic<T>::operator+= does not allow in-place change, since it
  returns T instead of T&
- Another work reduction in the isr, treat 'value' as `counter > 0`
  instead of relying on the notion that we can sometimes read the value
  with very low counter frequency
- Fix duplicated initializations
2020-09-26 10:56:08 +03:00
Max Prokhorov
da501a6bfa rpn: sleep and rtcmem ops (#2366) 2020-09-25 01:55:25 +03:00
Max Prokhorov
c7a95bf53f buttons: resistor ladder / analog buttons support (#2357)
- Buttons events source as button property instead of a global one
- Rename events source -> provider for all settings, consistent with the other things like relay and light providers
- AnalogPin to read between a certain analogRead() range
Trying to follow defaults here - analog 'press' is digital LOW, default value is HIGH, so no additional cfg entries are needed besides pin, level and changing evt source
- (debug) Refactor gpio command, add adc to show analogRead(pin)
- (debug) Add button command

Implemented based on:
https://gitter.im/tinkerman-cat/espurna?at=5f5d44c8df4af236f902e25d
https://gitter.im/tinkerman-cat/espurna?at=5f60e7f1f969413294e95370
2020-09-24 07:51:36 +03:00
Maxim Prokhorov
7dd8594a26 sns: default to SumFilter when counting values
Simplify fix for:
https://gitter.im/tinkerman-cat/espurna?at=5f6661a1f969413294f7404d

Most of the time, we care about the sum during report interval, not the
value that gets aggregated across all readings
2020-09-24 07:49:31 +03:00
Maxim Prokhorov
c0af41433a sns: clean-up EventSensor
Always do digitalRead() after ISR
Drop trigger, since we can handle this inside of reading routine
(although, pending some changes to make reading interval per-sensor)

Rework read / write through std::atomic
2020-09-24 07:49:31 +03:00
Max Prokhorov
c72ca3f1d0 sns: BME680 fixes (#2361)
- make sure we call run() before checking for errors, we will miss status update otherwise and lock the sensor class in the error state that it cannot recover from
- set error flag only when either bsec or bme680 report an error. ensure we show any issues reported by the library via the debug log
ref. https://gitter.im/tinkerman-cat/espurna?at=5f63a955c1d1a53705abcbe3
TODO: add custom error messages through virtual method?

Also, a minor fix to the sensors test when using 1m and 2m boards
2020-09-24 07:47:48 +03:00
user176176
1d895d98b8 hw: add support for Fcmila E27 7W RGB+W light bulb (#2353)
Device in question: https://www.aliexpress.com/item/32925895199.html
Named after print on the PCB.

Co-authored-by: user176176 <>
2020-09-15 23:40:37 +03:00
Max Prokhorov
21e9477d96 rpn: fix crash when calling rfb.codes 2020-09-10 01:15:32 +03:00
Max Prokhorov
d63228ef50 wifi: update to justwifi development version (#2347)
- support 32 byte hostname / ssid
- support 64 byte passphrase
- slightly reduce amount of memory allocations
- tweak initialization paths to call persistent(false) as early as possible
2020-09-10 01:05:02 +03:00
Max Prokhorov
ee1f56ad4b hw: rename zhilde eu44 -> 44eu (#2349) 2020-09-10 01:04:10 +03:00
Maxim Prokhorov
b8b8ca87b3 util: do not ignore zeroes in hex input
Provide safe fallback *only* when char is out-of-range

As it is, numeric 0 was equal to else { ... }, so 00 was never parsed.
Previously, it was assumed that we never try to parse leading / trailing zeroes,
but in turn we also ignored zeroes in the middle of the number...
2020-09-09 17:55:26 +03:00
Bert Vermeulen
f6ec2422a4 hw: add support for the Zhilde ZLD-64EU-W (#2342)
* Add support for the Zhilde ZLD-64EU-W

This is a power outlet with 6 power sockets and 4 USB ports.

* fixup based on the zld-44eu hw and tasmota template info

Co-authored-by: Maxim Prokhorov <prokhorov.max@outlook.com>
2020-09-04 23:08:28 +03:00
Maxim Prokhorov
e1b643fd00 pio: update ldpath as soon as possible
trying to fix #2343
*** [.pio\build\$PIOENV\firmware.bin] TypeError
`expected str, bytes or os.PathLike object, not Dir' trying to evaluate `${__get_flash_size(__env__)}'

as it turns out, PIO platform internals (sometimes) did not use the correct ldscript path
2020-09-04 23:00:40 +03:00
Maxim Prokhorov
3d1b82ea25 sns: fixup a409dede
vector will not copy when move ctor is marked noexcept
remove the copy ctor 'trick', re-add dtor. explicitly do the thing we want
(...clang-tidy would've shown this issue, something to do in the CI...)
2020-09-04 14:59:59 +03:00
Maxim Prokhorov
487190892e wifi: preliminary fix for leases setup order
see 69c65a6a40 (commitcomment-42008295)
Because of the way DHCP is integrated into the Core logic, we need to
call wifi_softap_add_dhcps_lease(...) inbetween WiFi.softApConfig(...) and WiFi.softAp(...)
2020-09-04 14:02:51 +03:00
Maxim Prokhorov
7c2fe35269 api: actually call PUT method of the handler 2020-09-04 14:01:41 +03:00
Maxim Prokhorov
e1a72e8790 rfb: move generic functions outside of the implementations block 2020-08-31 06:24:28 +03:00
Maxim Prokhorov
901dc2ed71 rfb: a little bit more RELAY_SUPPORT checks 2020-08-31 05:51:30 +03:00
Maxim Prokhorov
a409dedefe sns: fix internal flow
- magnitudes vector grows by calling copy ctor, ensure filter never gets deleted
- ensure we can't use magnitude member instead of ctor arg
- more magnitude references instead of using index access
- additional checks for isnan, fix report never triggering
- drop event callback. at least for EventSensor, we already have
  report with min / max value change triggers
2020-08-30 19:38:12 +03:00
Maxim Prokhorov
efdcdef196 sns: clean-up sensor init
- BaseFilter must have virtual dtor
- magnitude object is not trivial, we need to manage filter lifetime
- Ensure move also moves filter object
- Clean-up using magnitude object by value in functions
2020-08-30 15:43:23 +03:00
Max Prokhorov
a496308d97 web: prometheus metrics support (#2332)
- (experimental) provide generic way to read magnitude values
- expose /api/metrics with values formatted specifically for prometheus, with relay and sensor data
- small tweaks to sensor init

Example config:
```
scrape_configs:
  - job_name: 'espurna'
    metrics_path: '/api/metrics'
    params:
      apikey: ['apikeyapikey']
    static_configs:
      - targets: ['espurna-blabla.lan:80']
```
Where ESPurna side has
```
apiKey => "apikeyapikey"
apiEnabled => "1"
```
2020-08-30 15:26:16 +03:00
Maxim Prokhorov
ee58fa6511 rfb: parse payload in mqtt learn api, same as http
plus, hide both under `#if RELAY_SUPPORT`
2020-08-27 17:30:23 +03:00
Maxim Prokhorov
b363250766 rfb: fix parsing 'repeats' number in the payload
Ensure we step +1 char into the string
Ensure hex decoding of the payload ignores the separator + number of repeats
2020-08-27 17:29:31 +03:00
Max Prokhorov
6a2d57e547 rfb: #2335 follow-up (#2337)
* rfb: fix unused repeats setting
* rfb: rename TIMES -> REPEATS
* rfb: use out as first arg
2020-08-27 12:59:32 +03:00
Max Prokhorov
d399eac8cd hw: fix 512kb build with recent Core
ref. https://travis-ci.com/github/mcspr/espurna-nightly-builder/jobs/378203413#L698

> +env ESPURNA_FLAGS=-DGENERIC_ESP01_512KB ESPURNA_RELEASE_NAME=generic-esp01-512kb ESPURNA_BUILD_SINGLE_SOURCE=1 pio run -e esp8266-512k-base -s -t release
> /home/travis/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: .pio/build/esp8266-512k-base/firmware.elf section `.irom0.text' will not fit in region `irom0_0_seg'

Remove ~90Kb from the build.
2020-08-27 10:14:13 +03:00
Max Prokhorov
1f9479b943 rpn: rfbridge operators and mqtt fixes (#2302)
- cache received rfbridge codes in the internal list, allow to operate on it via the rpn operators
- add `<N> <proto> <code> rfb_match`, matching when we receive specified protocol + code string at least N times
- add `<proto> <code> <proto> <code> rfb_sequence`, checking if specified protocol + code pairs happen in sequence
- add `<TIME> <N> <proto> <code> rfb_match_wait` - similar to `rfb_match`, but waiting for at least `TIME` (ms) via oneshot runner
- add `<proto> <code> rfb_info`, pushes code's latest timestamp and it's counter on the stack
- add `<proto> <code> rfb_pop`, which removes the specified protocol + code from the internal cache
- fix MQTT skip setting making RPN variables absent on initial connection
- default to no skip when receiving MQTT
(small issue still stands with us having non-clean MQTT session, broker will persist variable subscriptions even after unsubscribe event)
2020-08-27 01:21:21 +03:00
Maxim Prokhorov
6d7fe1ce38 broker handles string 2020-08-27 00:04:04 +03:00
Maxim Prokhorov
9b3ef89dab Merge remote-tracking branch 'origin/dev' into rfb/refactoring 2020-08-26 23:00:45 +03:00