Commit Graph

2806 Commits

Author SHA1 Message Date
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
Max Prokhorov
e26ba9f52e Update platform_latest to Core 2.7.1 (#2263) 2020-05-27 01:10:10 +03:00
Max Prokhorov
b3fb066947 Bump to 1.15.0 (#2262)
* Version 1.15.0-dev

* changelog

* changelog
2020-05-27 00:37:02 +03:00
Max Prokhorov
8adbe08f5b Add apiSetup() back 2020-05-27 00:28:18 +03:00
Max Prokhorov
ff89504d39 WS refactoring (#2261)
* ws: clean-up wsPost implementation

- explain ourselves
- re-do consts, fix locality
- fix shadowing in ctors
- more consistent naming
- timeout for messages

* save 16 bytes temporary

* reference reference
2020-05-27 00:18:51 +03:00
Max Prokhorov
b8fc8cd1fd Terminal: change command-line parser (#2247)
Change the underlying command line handling:
- switch to a custom parser, inspired by redis / sds
- update terminalRegisterCommand signature, pass only bare minimum
- clean-up `help` & `commands`. update settings `set`, `get` and `del`
- allow our custom test suite to run command-line tests
- clean-up Stream IO to allow us to print large things into debug stream (for example, `eeprom.dump`)
- send parsing errors to the debug log

As a proof of concept, introduce `TERMINAL_MQTT_SUPPORT` and `TERMINAL_WEB_API_SUPPORT`
- MQTT subscribes to the `<root>/cmd/set` and sends response to the `<root>/cmd`. We can't output too much, as we don't have any large-send API.
- Web API listens to the `/api/cmd?apikey=...&line=...` (or PUT, params inside the body). This one is intended as a possible replacement of the `API_SUPPORT`. Internals introduce a 'task' around the AsyncWebServerRequest object that will simulate what WiFiClient does and push data into it continuously, switching between CONT and SYS.

Both are experimental. We only accept a single command and not every command is updated to use Print `ctx.output` object. We are also somewhat limited by the Print / Stream overall, perhaps I am overestimating the usefulness of Arduino compatibility to such an extent :)
Web API handler can also sometimes show only part of the result, whenever the command tries to yield() by itself waiting for something. Perhaps we would need to create a custom request handler for that specific use-case.
2020-05-25 23:41:37 +03:00
davebuk
18dea8902d Add '.example' files. (#2257)
* Add '.example' files.

Ref: #2232, add platformio_override.ini.example and custom.h.example files.

* Delete custom.h.example

* Delete platformio_override.ini.example

* Add files via upload

* Add files via upload

* Update custom.h.example

* Update custom.h.example

* Update platformio_override.ini.example
2020-05-21 05:02:55 +03:00
Max Prokhorov
1880d68475 espurna.h: reorder essentials (#2254)
- compat.h right after config
- remove broker.h from global header
- add 'hint' about eeprom methods into settings
2020-05-19 00:13:44 +03:00
Max Prokhorov
84b51cf680 broker: declare and define per module (#2253)
* broker: declare and define per module

We no longer need to specify each Broker type in broker.h
But, we exchange that bit for explicit initialization of the instance

Define helper macros to generate boilerplate code
- namespace with Instance, Register(), Publish()
- forward Register(...) -> Instance.Register(...),
  Publish(...) -> Instance.Publish(...)

* don't check for broker when deps enable it
2020-05-18 02:29:17 +03:00
Eric Chauvet
21e75bef51 Kingart curtain switch UI support (#2250)
* Completed kingart curtain switch support:
Added Web UI controls and view in status
Added power up behaviour (nothing, close, open, last position)
Added curtain style (Roller, etc...) for UI status and to be used in MQTT

* Checked commit before PR. Added html gulp static files generated.

* Corrected a code refactor error which make the MQTT messages not handling position from received messages. Added comment to debug tab to show how to enable debug

* Use the maximum compression for gzip. A byte is a byte :)

* Update code/espurna/curtain_kingart.cpp

Co-authored-by: Max Prokhorov <prokhorov.max@outlook.com>

* Variable name prefix update
Added public set position function and curtain count

* Added Scheduler new type : curtain

* Add curtain schedule support and correct the 12h bug when adding a slot (00:00 after refresh). Default Hour is 12h

* Code cleaning.
Schedule support.
Light support is having an issue with new schedules corrected here.

* I let do better by the specialists

* Curtain init statues

* Coding style corrections

* Removed debug stuff from now - will be back later with the right way

* rebuild webui

* revert 435f1c5e03 schHour default, rebuild ui

Co-authored-by: Eric Chauvet <eric.chauvet@test-tree.com>
Co-authored-by: Max Prokhorov <prokhorov.max@outlook.com>
2020-05-18 02:19:50 +03:00
CmPi
543eadcf9c Fix nofuss.cpp typo (#2251) 2020-05-18 02:09:09 +03:00
pezinek
d5dc1e029c rpn: $relayX variables were not populated on boot (#2246) 2020-05-12 23:08:34 +03:00
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