Commit Graph

3146 Commits

Author SHA1 Message Date
Maxim Prokhorov
fa3deeffbf webui: remove jquery dependencies and clean-up websocket API
Refactor WebUI:
- remove jquery dependency from the base custom.js and use vanilla JS
- remove jquery + jquery-datatables dependency from the RFM69 module
- replace jquery-datatables handlers with pure-css table + some basic cell filtering
  (may be incomplete, but tbh it is not worth additional 50Kb to the .bin size)
- introduce a common way to notify about the app errors, show small text notification
  at the top of the page instead of relying on user to find out about errors by using the Web Developer Tools
- replace <span name=...> with <span data-settings-key=...>
- replace <div> templates with <template>, disallowing modification
  without an explicit DOM clone
- run `eslint` on html/custom.js and `html-validate` on html/index.html,
  and fix issues detected by both tools

Streamline settings group handling in custom.js & index.html
- drop module-specific button-add-... in favour of button-add-settings-group
- only enforce data-settings-max requirement when the property actually exists
- re-create label for=... and input id=... when settings group is
  modified, so checkboxes refer to the correct element
- introduce additional data-... properties to generalize settings group additions
- introduce Enumerable object to track some common list elements for
  <select>, allow to re-create <option> list when messages come in
  different order

Minor fixes that also came with this:
- fix relay code incorrectly parsing the payload, causing no relay names
  to be displayed in the SWITCHES panel
- fix scheduler code accidentally combining keys b/c of the way C parses
  string literals on separate lines, without any commas in-between
- thermostat should not reference tmpUnit directly in the webui, replace with
  module-specific thermostatUnit that is handled on the device itself
- fix index.html initial setup invalid adminPass ids
- fix index.html layout when removing specific schedules
2021-07-18 23:30:32 +03:00
Maxim Prokhorov
256e790e4d webui: make sure the pointer data is set to null, otherwise the webserver will try to free() it 2021-07-18 22:41:51 +03:00
Maxim Prokhorov
6b2c34eaae alexa: display the used name in the webui 2021-07-18 22:41:50 +03:00
Maxim Prokhorov
658ce1056e rpn: make sure loop is actually reached after mqtt updates variables list 2021-07-06 09:19:05 +03:00
Maxim Prokhorov
50f247bd18 webui: fix scheduler template layout
Additional div made the mutator think we still have some active elements.
Also, small clean-up for type consistency in the WS part.
2021-07-05 03:26:38 +03:00
Maxim Prokhorov
526a5dd239 webui: always initialize checkbox with the unique id
even when the cfg object does not list it, like with scheduler button
trying to fix #2459
2021-07-04 22:55:48 +03:00
Maxim Prokhorov
32b864c563 rpn: apply mqtt variables before running rules
since some of them are allowed to yeild(), don't change things while it is already running
2021-07-04 22:55:48 +03:00
Maxim Prokhorov
68436f1e72 pio: update platform_latest
Build with Core 3.0.1 release and update the git toolchain to match the upstream
2021-06-29 23:25:24 +03:00
Max Prokhorov
e6b6a69157 mqtt: do not compose will topic twice
fix #2457
2021-06-27 19:26:14 +03:00
Maxim Prokhorov
44298d4077 terminal: +OK instead of just OK
Amends 7ea73554
2021-06-23 20:30:38 +03:00
Maxim Prokhorov
33032f0ebe mdns: no need to track services when starting the server 2021-06-23 20:29:32 +03:00
Maxim Prokhorov
06fa5b1c6d mqtt: refactoring & mdns autoconnect tweaks
- generic mdns query function so we don't forget about the removeQuery()
- full handle mdns logic in the mqtt module, check for running mdns
instance and periodically poll for _mqtt._tcp service
- autoconnect only when MQTT is enabled *and* there is no server
- use mqtt::settings and mqtt::build namespaces for settings
- some refactoring for topic <-> setting application
- prefer const String& to const char* in topic generation
2021-06-23 20:12:28 +03:00
Maxim Prokhorov
19f3214578 i2c: amend 2be8d10601 and at least make brzo buildable 2021-06-23 00:42:32 +03:00
Maxim Prokhorov
c056c54db4 sns: amend ADS1X115 I2CPort to use common gain & datarate settings
ref. #1033, this could be used as-is with a generic analog sensor code
by substituting ::analogRead(channel) with I2CPort::read(channel)
2021-06-23 00:42:16 +03:00
Maxim Prokhorov
bacff3102d pio: make sure "y" for shared libs still works
And update other options to support y, yes and true
2021-06-20 17:41:46 +03:00
Maxim Prokhorov
c34acf1748 ci: latest Core and split webui test into a separate job 2021-06-20 17:25:20 +03:00
Maxim Prokhorov
f18f128e4b pio: consistent shared libs location
Do not install libraries globally in CI, use the specified PIO .ini option.
Similar to the other package installers, prefer package cache to the actual library storage contents.
2021-06-19 12:52:10 +03:00
Maxim Prokhorov
1600fcc133 settings: hide kv_store from the public header
More concise foreach, generic template code also no longer expands down to ::_read_kv
Also helps with needless inlining happening with recent gcc versions
2021-06-18 17:27:49 +03:00
Maxim Prokhorov
c51b6e99f1 curtain: add missing flags & fix typos when module is active 2021-06-18 12:31:18 +03:00
Maxim Prokhorov
a9220ec2b2 pio: pin lib_deps versions and owners 2021-06-18 12:12:09 +03:00
Maxim Prokhorov
310b063eb1 sns: basesensor methods do not qualify for constexpr
Quoting gcc-4.8.2

> espurna/sensors/BaseAnalogEmonSensor.h:19:7: note: 'BaseAnalogEmonSensor' is not literal because:
> class BaseAnalogEmonSensor : public BaseEmonSensor {
>       ^
> espurna/sensors/BaseAnalogEmonSensor.h:19:7: note:   'BaseAnalogEmonSensor' has a non-trivial destructor
2021-06-18 12:12:09 +03:00
Maxim Prokhorov
1a36efb8f2 sns: rename generic pwr keys with a typed prefix
Ratio, Mains are specific to a magnitude type.
Make keys use global index, and do a (temporary) WebUI workaround
to use 0 index instead of the global key.
Migrate to the new settings keys.

Local magnitude-specific index is still in play, pending changes in the rest of sensors
(ADE7953, PZEM004T{,V30}, ...) to remove it completely.

Local sensor index could still be useful though, to help out with some settings
in the future as we don't really enforce magnitude type uniqueness within sensors.
2021-06-18 12:12:09 +03:00
Maxim Prokhorov
23da0b74d4 pio: use swserial from the Core 2021-06-18 12:12:09 +03:00
Maxim Prokhorov
c136678a4f sns: tweak analogRead frequency
Locks the value to the latest one for a bit. Another option would be
to yield() / delay(...) to spend the time somewhere else.
2021-06-18 12:12:09 +03:00
Maxim Prokhorov
b19905a306 sns: EmonSensor fixes and refactoring
- fix dubious pinMode(0, INPUT), which does not work with esp8266 as A0 != GPIO0
- I2C sensor locking code can now exist separately from the base class
- EmonSensor -> BaseAnalogEmonSensor
- move AnalogEmon-specific methods from BaseEmonSensor to BaseAnalogEmonSensor
- clean-up protected member usage across the base, force the class to implement certain methods instead
- more code reuse between sensor versions
- drop local magnitude indexes & shared arrays of values in favour of separate
class instances, refactor ADS1X115 to the new model
- (techically) allow ADS1X115 code to be used with more than one i2c address
by having a shared port instance
2021-06-18 12:12:09 +03:00
Maxim Prokhorov
ff11e5814f sns: A0 is not GPIO0 2021-06-18 12:12:09 +03:00
Maxim Prokhorov
6ba5f95e87 sns: typo when getting local index for Nth magnitude 2021-06-18 12:12:08 +03:00
Maxim Prokhorov
a1e7941fa6 scripts: some more Core version fixes
Remove 2.3.0 code for ldscripts
Update
2021-06-18 12:12:08 +03:00
Maxim Prokhorov
939f4afa0a sns: ICACHE_RAM_ATTR -> IRAM_ATTR
3.0.0 now uses macro from esp-idf
avoid deprecation warnings for the source here
(still shows it with the libs though, when building without -w)
2021-06-17 16:41:38 +03:00
Maxim Prokhorov
d36127963c scripts: comments 2021-06-09 12:45:14 +03:00
Maxim Prokhorov
0422d61c69 nofuss: bump to the forked 0.4.0
Make sure it does not have global flags related to the HTTPCLIENT
Use generic ::updateFS with updater, and also support generic "fs" key
in the server response
2021-06-09 12:42:32 +03:00
Maxim Prokhorov
bd3a588977 hardware: lightfox fixes & buttonAdd
Should be buildable once again

Restore the behaviour from #1468, where button clicks were triggered
Inject relay provider using the relayAdd, add buttonAdd to provide input handling

Remove extra button handling code from the WebUI

Still assuming that DUAL code really needs a syncronized way to handle
input & output with relays, so we can't treat it as a real button.
Without the device it is only guessing, and various issues / comments
are not really clear on that part :/
2021-06-09 11:20:07 +03:00
Maxim Prokhorov
75b51f1e80 scripts: restore old build.sh and fixup release.sh generator
Leave build.sh as a local script, assume that CI will use the release.sh instead
Generator parser returned None at the end (...this is not rust...), also
fix args.* typos with a more declarative structure.
2021-06-08 13:22:25 +03:00
Maxim Prokhorov
74e18a59bc scripts: update build.sh
- remove version handling, PIO already does this for us
- directly set generate_release_sh.py arguments instead of having a
getopt proxy for each one (and having to deal with short-arg support)
- slightly more logs for the build process
2021-06-07 03:54:47 +03:00
Maxim Prokhorov
4c33cacfdb pio: add build-and-copy, more configuration options for version
Multiple ways to specify version string through environment variables:
- `ESPURNA_BUILD_FULL_VERSION` to set full version string
By default it is empty, and the version is combined using the values specified below
- `ESPURNA_BUILD_VERSION` to modify the first part of the version string (1.15.0-dev)
By default, uses espurna/config/version.h APP_VERSION value
- `ESPURNA_BUILD_REVISION` to specify revision part of the version string
For example 12345678, which is expanded as either .git12345678 or -git12345678
(depending on whether the version string contains hyphen)
By default, use git to retrieve the first 8 characters of the current HEAD SHA value
- `ESPURNA_BUILD_VERSION_SUFFIX` to specify build metadata part of the string
For example nightly20210607, which is added to the full version as 1.15.0-dev+nightly20210607
Empty by defauld

Adds -t build-and-copy which uses the values above to copy firmware.bin, configurable with:
- `ESPURNA_BUILD_NAME` to set the suffix of the filename.
By default, uses the $PIOENV (aka the string after the env: in the .ini file)
- `ESPURNA_BUILD_DESTINATION` to specify where to copy the .bin files
By default, uses $PROJECT_DIR

Resulting file is stored at:
${ESPURNA_BUILD_DESTINATION}/${ESPURNA_BUILD_FULL_VERSION}/espurna-${ESPURNA_BUILD_FULL_VERSION}-${ESPURNA_BUILD_NAME}.bin

In addition, modify generate_release_sh.py to use the new environment variables.
2021-06-07 03:54:28 +03:00
Maxim Prokhorov
c945c239ea scheduler: fixup web api and functions usage
- make use of scheduler::settings when listing schedules
- do not be overzealous with settings validation & parsing
- cleaner wildcard() usage, we return a String not a ref to something internal.
but, it is techically allowed to use `const T&` for a `T` temporary which will be destroyed
after the apiRegister() callback returns
2021-05-30 05:53:13 +03:00
Maxim Prokhorov
492693054f scheduler: bump cfg version 2021-05-30 05:53:13 +03:00
Maxim Prokhorov
e298217ed1 scheduler: rebuild webui 2021-05-30 05:53:13 +03:00
Maxim Prokhorov
e22f67e5d6 scheduler: fix schedule restore flag & refactoring
Restore was unintentionally broken after switching from per-relay to
per-schedule setting. Instead of using schedules count it used the
number of relays (or curtains), and never light channels.

Instead, loop over available schedules and check the 'restore' flag,
calling the action when the schedule was supposed to be active.
Similar to the old approach, check for the most recent action and call
it (also, discarding the same type & target pairs, to avoid scheduling
conflicting actions)

time_t seconds offset is refactored into tm.tm_mday offset.
this causes the function to only work with local time, however
it *should* correctly offset day-by-day in case it somehow stumbles
upon dst transition

For settings:
- schSwitch renamed into schTarget
- schTarget default is no longer 0xff, but 0
- schType is a mandatory setting, instead of 1 (switch) default to 0 (none)
- move getSetting into functions to reduce code size
- delSetting case moved into the initial block that runs before restore() and check()

Plus, refactor C-style naming into namespaces similar to the other modules
2021-05-30 05:53:13 +03:00
Maxim Prokhorov
71ddf35022 settings: fix saving base2 integers
Buffer size of 16 is not enough for the output, bump to 32

Specific bug can be triggered by adding >16 relays and using RelayMask
Since the used API does not check buffer size at all, it ended up
overwriting the stack just before the callsite. e.g. relay boot would
show relay count as 48 (aka '0')

Remove explicit reserve() as well, buffer concat will take care of that
2021-05-20 16:02:34 +03:00
Maxim Prokhorov
3078ad16c7 webui: input name should match key prefix 2021-05-17 03:51:13 +03:00
Maxim Prokhorov
f1d1ed01da scheduler: fix order of keys for the webui 2021-05-17 03:50:27 +03:00
Maxim Prokhorov
648b45087d webui: select[.isrelay] was missing names 2021-05-17 03:47:20 +03:00
Maxim Prokhorov
8892122091 webui: rebuild static files 2021-05-13 08:21:23 +03:00
dependabot[bot]
18e1d3a6d2 webui: bump hosted-git-info from 2.8.8 to 2.8.9 (#2446)
Bumps [hosted-git-info](https://github.com/npm/hosted-git-info) from 2.8.8 to 2.8.9.
- [Release notes](https://github.com/npm/hosted-git-info/releases)
- [Changelog](https://github.com/npm/hosted-git-info/blob/v2.8.9/CHANGELOG.md)
- [Commits](https://github.com/npm/hosted-git-info/compare/v2.8.8...v2.8.9)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-13 08:18:43 +03:00
dependabot[bot]
1f7ede8334 webui: bump lodash from 4.17.20 to 4.17.21 (#2445)
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.20 to 4.17.21.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.20...4.17.21)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-13 08:18:19 +03:00
Xose Pérez
bb7ffe9b3c sensor: add support for SmartMeasure SM300D2-VO2 air quality multi-sensor (#2447)
* Support for SmartMeasure SM300D2-VO2 air quality multi-sensor

* Fix temperature sign, using hexDecode

* Update README.md
2021-05-12 16:24:59 +03:00
m-kozlowski
4612948d95 webui: fix dcz and thingspeak templates not being populated (#2443)
* Fix for domoticz relay IDs not being populated with stored values

* Fix for domoticz relay IDs not being populated with stored values - part 2: magnitudes

Co-authored-by: mkozlowski <gitcmt@empeka.pl>
2021-05-05 03:20:21 +03:00
Maxim Prokhorov
2c91a44334 wifi: handle static config without WiFi::config
Referencing currently used code for the NONOS, plus some Core-specific
things to handle lwip1.4 <-> lwip2 layer

Saves a bit of code handling Arduino WiFi Shield compatibility,
which we don't really need
2021-04-25 02:01:14 +03:00
Maxim Prokhorov
9f64684656 wifi: try to workaround unexpected STAMODE_DISCONNECTED event
Or, at least try to.
wifi_station_disconnect() queues the event, but receiving it will confuse the
connection loop waiting for the one right after wifi_station_connect()

Event SSID is the last connected one, reason is REASON_AUTH_FAIL (202)
Simply switch contexts to allow the event handler to run.
2021-04-25 02:01:14 +03:00