Commit Graph

2829 Commits

Author SHA1 Message Date
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
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
Maxim Prokhorov
d03f8a7399 rfb: let API show learning status 2020-08-13 16:54:37 +03:00
Maxim Prokhorov
f3c185cc73 api: rework storage & json calls, drop std::function
- reduce overall size of the structure, store a single required entity
  inside of Api object itself.
- tweak internal functions to expect a certain path size
- (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
  when 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
2020-08-13 16:54:36 +03:00
Maxim Prokhorov
a453aa1296 relay: share dummypin instance
- no need for smartptr when instance is static
- default ctor, set default values in the body
2020-08-13 16:53:52 +03:00
mkozlowski
fe6386cfe9 Allow domoticz dimmer device to control LIGHT_PROVIDER_DIMMER brightness 2020-08-11 23:31:41 +02:00
m-kozlowski
f849dc4111 domoticz: fix idx truncation when reading from settings (#2316)
Co-authored-by: mkozlowski <gitcmt@empeka.pl>
2020-08-11 15:32:37 +03:00
Max Prokhorov
2b69c7eb6d rpn: update to rpnlib 0.24.1 (#2314)
* rpn: bump to rpnlib 0.24.1

- `i` and `u` suffixes for numbers in expressions, parse as Integer or Unsigned respectively
- `checkedTo...()` method variants for numeric conversions
- strings can contain escape sequences (\x61\x62\x63, \n, \t, \r)
- improve float number parsing
- more consistent whitespace checks, tokens also can be separated by \n or \t
- various parser fixes

* fix captures
2020-08-10 20:13:12 +03:00
Max Prokhorov
1df4a1aaa2 debug: use rfc5424 format when adding syslog header (#2315) 2020-08-10 20:12:18 +03:00
Max Prokhorov
8510f77d12 pio: use gcc10.1 package from registry
ref.
https://github.com/platformio/platform-espressif8266/issues/224#issuecomment-667053958
https://bintray.com/platformio/dl-packages/toolchain-xtensa/2.100100.200706
2020-08-02 13:36:15 +03:00
Max Prokhorov
35305f1f36 Update rpnlib to 0.23.x (#2274)
## [0.23.0] 2020-07-26
### Added
- `p` operator to print the top of the stack via debug function
- `&var` syntax to create variable reference in expression
- `=` operator for variable assignment in expression
- `exists` operator to check for variable existance (only for references)
- `deref` operator to convert variable reference into a value (only for references)
- Allow to use either float or double as floating type, parse numbers in expressions as specified type
- Add boolean type, parse `true` and `false` in expressions
- Add null type, parse `null` in expressions
- Add string type, parse double-quoted `"string"` in expressions
- Add integer and unsigned integer type, used in operators
- Allow to configure underlying types from rpnlib\_config.h and -D... flags
- Return `rpn_error` from operators, split error types into categories
- Create a new stack by using `[` keyword. Move stack contents into the previous stack + size by using `]`.

### Changed
- Stack structure no longer holds raw `float`, but internal `rpn_value` type
- rpn\_... setter and getter methods use `rpn_value` type
- Operator functions return `rpn_error` type, allowing to return both value and operator errors
- Variables in expressions are no longer required to exist when using `&var`
  Expression will automatically create the variable, set it to `null` and push it's reference on the stack
- It is possible to create 'reference' stack values
- Improve precision of `e` and `pi`

### Fixed
- Proper value for `e` constant
- Allow to use multiple contexts simultaniously, replace `rpn_error` and `rpn_debug_callback`
  with the current `rpn_context` members `error` and `debug_callback` respectively
2020-08-02 13:14:44 +03:00
Rui Marinho
15819d7c18 general.h: fix comment typo (#2311) 2020-08-02 09:13:52 +03:00
Rui Marinho
6266930a4d sns: Add BME680 (#2295)
Add support for BME680 using libalgobsec proprietary algorithms for precise Indoor Air Quality (IAQ) measurement. Unlike traditional CO2 sensors - and good ones are expensive - it measures nearly all VOCs compounds in the air (plus other gases) and compensates those measurements with its built-in temperature and humidity sensors to determine indoor air quality.

Co-authored-by: Max Prokhorov <prokhorov.max@outlook.com>
2020-08-02 09:12:38 +03:00
Maxim Prokhorov
6919d11eca utils: fix hexEncode / hexDecode out-of-bounds index
Using generic size type instead of unsigned char
2020-07-25 04:44:44 +03:00
Maxim Prokhorov
5e5d0d0dd7 relay: don't init RelaysMax relays when using rfbridge provider 2020-07-25 04:44:44 +03:00
Rui Marinho
ea111c4cf2 sns: set pH decimals to 3 (#2306) 2020-07-19 23:30:59 +03:00
Max Prokhorov
2dcb5ea748 sns: revert "Power factor fixes" (#2304)
This reverts commit d57eb0721b.

We can use raw value as-is. While the lack of unit is true for the value represented as cos θ , we don't specifically have any other sensors using it as such. As comment suggest (huh), we want to express the thing as a percentage.
2020-07-18 18:55:19 +03:00
Max Prokhorov
d57eb0721b sns: power factor fixes (#2303)
* Update PZEM004TV30Sensor.h

See table above for the correct scale

* Power factor has no unit
2020-07-18 01:09:38 +03:00
Maxim Prokhorov
baa3426f19 ci: fix codacy style complaints 2020-07-16 23:05:01 +03:00
Maxim Prokhorov
436827eb90 relay: fix building with rfbridge provider 2020-07-16 22:59:13 +03:00
Maxim Prokhorov
8e49523710 test: add --no-single-source to check whether normal build process works 2020-07-16 05:27:42 +03:00
Maxim Prokhorov
3d7449c202 Include library headers in .cpp 2020-07-16 05:27:42 +03:00
Maxim Prokhorov
b7a01466fc pio: fix lib_deps order
See https://github.com/platformio/platformio-core/issues/3598
2020-07-16 05:27:42 +03:00
Maxim Prokhorov
a2e0d243cb settings: internal storage fixes
- revert unintended change to include 2 bytes as part of empty value
  fixes compatibility with old versions including Embedis and having empty values
- overwrite now empty space when moving
- re-shuffle internal logic to be more strict with cursor oob read / writes
- update comments
2020-07-16 05:27:42 +03:00
Maxim Prokhorov
d7711873d5 mcp23s08: fix (c) notice 2020-07-16 05:20:38 +03:00
dpeddi
547f52fe79 hw: Implement support for ProDino WIFI (#2269)
- implement mcp23s08
- support mcp pins in relays and buttons
- add hardware profile for ProDino WiFi

Co-authored-by: dpeddi <dpeddi@gmail.com>
Co-authored-by: Maxim Prokhorov <prokhorov.max@outlook.com>
2020-07-16 05:15:34 +03:00
Max Prokhorov
33ff98c2c6 ota.py: don't use deprecated zeroconf attrs (#2299)
Also bump zeroconf to the version used by PIO
2020-07-09 00:51:36 +03:00
Max Prokhorov
2be8d10601 PIO: fix git, bump versions (#2298)
- bump to espressif8266@2.5.3 (but, 2.5.4 will be here soon...)
- pwm asm -> __asm__
- re-shuffle dependencies a bit, remove brzo from -git and -latest, ref https://github.com/pasko-zh/brzo_i2c/issues/40
2020-07-08 17:44:29 +03:00
Max Prokhorov
009bdf05ef wifi: separate softAp settings (#2294)
- replace `apmode` with `wifiApMode`
- deprecate `WIFI_FALLBACK_APMODE` in favour of the AP mode setting
- allow to set custom SSID and passphrase for the softAP via `wifiApSsid` & `wifiApPass`
- identifier fallback for hostname
2020-07-04 15:49:41 +03:00
Maxim Prokhorov
57f5c7dc98 sns/cse7766: fix pin naming 2020-07-04 12:44:47 +03:00
Maxim Prokhorov
a6af8140b1 sns: fix SoftwareSerial ctor for recent versions 2020-07-04 12:44:47 +03:00
Max Prokhorov
7b57274d1f sensor: Add PZEM004T V3.0 (#2283)
Add new V3.0 version of PZEM004T, not tested. Default to factory default address 0xf8, configurable through pzemv30Addr 8-bit number
Add 'frequency' measurement & 'hz' unit
Add pz.address that configures address
Implemented energy reset

Right now we only support a single device. No way to test this properly (mostly, how exactly we need to connect this stuff), so left as not implemented.
2020-07-03 23:25:33 +03:00
Max Prokhorov
d479ebd6cb sns/hdc1080: check device id instead of serial (#2270) (#2291)
- document device ID logic
- log when we receive unexpected device ID
- don't fall-thought to '_ready=true' when not ready
2020-07-03 22:52:31 +03:00
Max Prokhorov
1583548c3a sns: more magnitude settings (#2290)
- introduce zero threshold setting to reset value to 0 below a certain point (resolve #2264)
for example, set pwrPZeroThreshold0 10.0 for active power (or pwrQ... for apparent, pwrModS... for reactive) will reset always reset value to 0, similar to what turned off relay does. Default value is nan, since we can't use 0.0 on account of negative values.
- fix energy magnitude indexes usage, properly reset in API
- simplify sending pwr and emon Visible flags
- allow to use settings prefixes more, remove snsMinDelta & snsMaxDelta and use relative magnitude indexes
2020-07-03 22:48:28 +03:00
Max Prokhorov
3145e8be24 Rework settings (#2282)
* wip based on early draft. todo benchmarking

* fixup eraser, assume keys are unique

* fix cursor copy, test removal at random

* small benchmark via permutations. todo lambdas and novirtual

* fix empty condition / reset

* overwrite optimizations, fix move offsets overflows

* ...erase using 0xff instead of 0

* test the theory with code, different length kv were bugged

* try to check for out-of-bounds writes / reads

* style

* trying to fix mover again

* clarify length, defend against reading len on edge

* fix uncommited rewind change

* prove space assumptions

* more concise traces, fix move condition (agrh!!!)

* slightly more internal knowledge (estimates API?)

* make sure cursor is only valid within the range

* ensure 0 does not blow things

* go back up

* cursor comments

* comments

* rewrite writes through cursor

* in del too

* estimate kv storage requirements, return available size

* move raw erase / move into a method, allow ::set to avoid scanning storage twice

* refactor naming, use in code

* amend storage slicing test

* fix crash handler offsets, cleanup configuration

* start -> begin

* eeprom readiness

* dependencies

* unused

* SPI_FLASH constants for older Core

* vtables -> templates

* less include dependencies

* gcov help, move estimate outside of the class

* writer position can never match, use begin + offset

* tweak save_crash to trigger only once in a serious crash

* doh, header function should be inline

* foreach api, tweak structs for public api

* use test helper class

* when not using foreach, move cursor reset closer to the loop using read_kv

* coverage comments, fix typo in tests decltype

* ensure set() does not break with offset

* make codacy happy again
2020-07-03 22:07:48 +03:00
Matt Black
774a73d1d4 Including support for Arlec PC190HA/PB89HA (#2286) 2020-06-27 07:54:58 +03:00
Andrej Peterka
3e28ebf24f Add support for AG-L4 v3 (#2276) 2020-06-27 07:54:21 +03:00
Max Prokhorov
7aec0c57eb hardware: test nedis-wifip310fwt-sensor 2020-06-08 00:21:35 +03:00
Max Prokhorov
ba9b4a4503 hardware: Add support for Nedis WIFIP310FWT (#2275) 2020-06-07 22:35:02 +03:00
Max Prokhorov
5f90c7c3bc RPN: check relay status before triggering (#2268)
* rpn: check status to avoid rescheduling

* keep existing op, add name hint
2020-06-07 19:12:04 +03:00
Max Prokhorov
d9cb35f781 sensor: streamline correction settings (#2265)
* wip

* template common operation

* more

* ui

* fix naming issues

* remove old constraints

* oops

* dummy sensor

* rearrange bmx280 magnitudes
2020-05-31 05:49:34 +03:00
Max Prokhorov
cb8443dfa3 Use #include for single source build (#2267)
* [1/2] use #include for single source

* [2/2] use #include for single source
2020-05-31 05:48:47 +03:00