Commit Graph

2869 Commits

Author SHA1 Message Date
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
Maxim Prokhorov
0425fa7756 rfb receiver lock for multiple relays 2020-08-26 22:59:11 +03:00
Maxim Prokhorov
22924cfd0a simplify rc-switch reader 2020-08-26 22:59:11 +03:00
Maxim Prokhorov
5028bbdcf0 fix sender timing typo, fix code unpacking 2020-08-26 22:59:11 +03:00
Maxim Prokhorov
dc8a672e00 ... on second thought, just bump the cfg version 2020-08-26 22:59:11 +03:00
Maxim Prokhorov
17814d8003 settings: fix migrate routine never working with empty settings 2020-08-26 22:56:17 +03:00
Maxim Prokhorov
844d0b4c53 pio: remove the note about PIO incompatibility
ref. 6af2bad123
2.3.0 is still not supported, but at least buildable
2020-08-26 22:54:38 +03:00
Maxim Prokhorov
378cfdc09a settings backwards compat on demand 2020-08-26 10:57:23 +03:00
Maxim Prokhorov
4b93369706 fix not reading_until_length after buckets 2020-08-26 09:17:44 +03:00
Maxim Prokhorov
2fc0ab0a17 tweak logging 2020-08-25 23:21:49 +03:00
Maxim Prokhorov
8b01c29a28 learnok was never matched as length+payload 2020-08-25 23:21:49 +03:00
Maxim Prokhorov
a43dc16825 recover learn codes from old source
ref.
https://github.com/Portisch/RF-Bridge-EFM8BB1/wiki/0xA2 (desc: Learning OK)
https://github.com/Portisch/RF-Bridge-EFM8BB1/wiki/0xA3 (desc: Learning failed)
were used, but the pages did not reflect the actual implementation:

af1bddb3d8/inc/uart.h
...
RF_CODE_LEARN_KO = 0xA2
RF_CODE_LEARN_OK = 0xA3
...
2020-08-25 23:17:55 +03:00
Maxim Prokhorov
11f815fc69 cleanup 3
- no need in template when size set as constexpr
- remove size param completely, deduce size based on buffer
2020-08-25 22:24:21 +03:00
Maxim Prokhorov
40a387522d cleanup 2
- queueing efm8bb1 msg, pass around array as reference since the size is fixed
- make use of learn timestamp
2020-08-25 21:29:55 +03:00
Maxim Prokhorov
2e77818ae1 cleanup 2020-08-25 20:11:39 +03:00
Maxim Prokhorov
7cfde70d85 broker publish with protocol included 2020-08-25 20:10:40 +03:00
Maxim Prokhorov
83e22b09cd codacy 2020-08-25 15:40:44 +03:00
Maxim Prokhorov
9bc8afe81c use correct rfb_provider for stock rfbridge env 2020-08-25 15:25:16 +03:00
Maxim Prokhorov
61daecee05 log advanced sniffing methods of efm8bb1 alternative fw 2020-08-25 15:24:35 +03:00
Maxim Prokhorov
8e6c474160 fix debug log 2020-08-25 14:07:47 +03:00
Maxim Prokhorov
d7e32ec866 fix hexDecode result check for rfraw & rfb.write 2020-08-25 14:07:47 +03:00
Maxim Prokhorov
b8db57e460 fix hexDecode result & input checks
- for some reason we were never checking it's output
no need to increase +1 since we write the exact number
- allow hexEncode output be decoded, enforce even-ness
- raw msg must have at least 3 bytes - start+code+end
2020-08-25 14:07:29 +03:00
Maxim Prokhorov
81358d98a3 forgot 1 byte prefix 2020-08-23 23:43:43 +03:00
Maxim Prokhorov
82b06536b3 codacy, fix not setting the protocol when sending 2020-08-23 21:31:16 +03:00
Maxim Prokhorov
5da8c5262e fixup! fixup deprecated flags migration 2020-08-23 21:05:17 +03:00
Maxim Prokhorov
3cc9aa6853 try to fix build with gcc4.8 2020-08-23 12:06:31 +03:00
Maxim Prokhorov
741302e7bd fix webui flags 2020-08-23 11:57:04 +03:00
Maxim Prokhorov
a51b57b57d fix rfbridge-direct pio env 2020-08-23 11:56:07 +03:00
Maxim Prokhorov
e19c16e222 Merge remote-tracking branch 'origin/dev' into rfb/refactoring 2020-08-23 11:54:21 +03:00
Maxim Prokhorov
02cff4607d fixup deprecated flags migration 2020-08-23 11:54:01 +03:00
Maxim Prokhorov
7a24806adb test: try using rc-switch from open-mqtt-gateway 2020-08-23 11:50:59 +03:00
Maxim Prokhorov
f890a06fc5 rfb refactoring
- RF_... -> RFB_...
- rework rcswitch integration, support variable length payload
- rework rfbridge parser (not tested)
- rework settings scanning routine when trying to match rf payload
  with the relay ID
- update build tests
2020-08-23 11:48:50 +03:00
Max Prokhorov
210a6601bc libs: fix relative include path
resolve #2326
2020-08-22 01:55:15 +03:00
Max Prokhorov
1d957506b3 PIO: remove Arduino Core 2.3.0 support (#2333)
As this is no longer an option since PIO 4.4.0
ref.
04694b4126
https://docs.platformio.org/en/latest/core/history.html

*...I have known you for so long
When we ran in circles...*
2020-08-22 01:36:44 +03:00
Maxim Prokhorov
0f11b662a1 compat: c++ alternative to the UNUSED / void-cast macro 2020-08-15 02:37:59 +03:00
Alex. Tircovnicu
e8b80845bc ir: fixed build error in case IR TX is not used in raw mode 2020-08-14 23:14:44 +03:00
Alex. Tircovnicu
22f0b9b0d3 ha: fix swapped device model and manufacturer fields in the discovery 2020-08-14 23:14:24 +03:00
Max Prokhorov
ff1c9e4991 domoticz: allow dimmer device to control brightness (#2317)
Per PR comment:
> I'm running simple 1-channel led dimmer and couldn't get brightness control working, as it was called only if lightHasColor().
> This PR changes conditions slightly, and allows domoticz's dimmer device to control brightness as well. I think this device type is more appropriate/comfortable in this case."

- remove lightHasColor() check, try to parse the payload and manually adjust the channels
- when domoticz payload does not have "Color" field, still fall-through to the brightness update
2020-08-13 18:06:39 +03:00
Max Prokhorov
6f98861ce1 Merge pull request #2321 from mcspr/api/no-std-func
- share relay dummypin instance between relay objects, replace unique_ptr with basic pointer (as we never destroy things, everything is brought up on boot and is essentially static)
- reduce overall size of the Api (web_api_t) structure, store a single required unsigned char id inside of the Api object itself.
- drop std::function for the same reason, current implementation only needs a single u8 ID in all cases
- tweak internal functions to expect a certain path size, drop strange comparisons with sprintf return value
- (kind of a hack) add manual calls to vector<Api>::reserve() as we go over the current capacity and vector increases it's size times 2. e.g. for 9 relays, we would allocate space for 32 Api objects as vector size goes from 16 to 32, after we add 18 Api objects with relay + pulse
- (breaking) json calls on a separate path, don't waste time encoding a single entity as json object when we can encode more things
- rfbridge API learn will return the current status instead of a plain OK
2020-08-13 17:43:51 +03:00
Max Prokhorov
69c65a6a40 wifi: softap dhcp leases (#2320)
Remember MAC for the current IP sequence number
(e.g. lease 0 -> xxx.xxx.xxx.2, lease 1 -> xxx.xxx.xxx.3 and etc.)

~500 bytes of code
2020-08-13 17:42:38 +03:00
Max Prokhorov
b718636ecc Fix unused vars
As codacy points out, move stype and switchType to the LIGHT_PROVIDER != NONE block
2020-08-13 17:00:30 +03:00