Commit Graph

2522 Commits

Author SHA1 Message Date
Bernhard Kirchen
20ecf2a66b powermeter refactor: add and use HttpGetter class
this new class uses the newly introduced HttpRequestConfig and performs
HTTP requests using this config. it will be reused for other power
meters (SML over HTTP(S)) and may be reused by other features in the
future (battery provider, solar power provider, etc.).
2024-06-27 22:18:41 +02:00
Bernhard Kirchen
4d99e87ef4 powermeter: add example URL with non-default TCP port 2024-06-26 21:25:08 +02:00
Bernhard Kirchen
6da90de765 remove extraction of basic auth params from URL
the extractUrlComponents method did extract username and password
from the URL and encoded it for basic authentication. however, the
respective result string was never used. we only perform basic
authentication if the auth type is "basic" and if username and
password were supplied through the respective inputs.
2024-06-26 21:25:08 +02:00
Bernhard Kirchen
297b149f84 powermeter refactor: generalize HTTP request config
the parameters to peform an HTTP request by the HTTP(S)+JSON power meter
have been generalized by introducing a new config struct. this is now
used for all values which the HTTP(S)+JSON power meter can retrieve, and
also used by the HTTP+SML power meter implementation. we anticipate that
other feature will use this config as well.

generalizing also allows to share serialization and deserialization
methods in the configuration handler and the web API handler, leading to
de-duplication of code and reduced flash memory usage.

a new web UI component is implemented to manage a set of HTTP request
settings.
2024-06-26 21:25:08 +02:00
Bernhard Kirchen
ccba7d8036 move JSON path resolver to Utils class for re-use 2024-06-26 21:25:05 +02:00
Bernhard Kirchen
673b9f4fa8 powermeter refactor: use destructors to de-initialize 2024-06-26 20:51:56 +02:00
Bernhard Kirchen
e78f5849c1 Feature: decode more OBIS values in SML power meters
supersedes #951.
2024-06-26 20:51:56 +02:00
Bernhard Kirchen
75c07c17f2 powermeter refactor: SML lib: replace double by float
avoid additional conversions and avoid double for the fact that
calculations on type double are implemented in software, whereas
float is handled in hardware on ESP32.
2024-06-26 20:51:56 +02:00
Bernhard Kirchen
6108d24795 powermeter refactor: introduce PowerMeterSml
this new class handles SML data. it uses the SML lib to decode values
and manages those. this de-duplicates code as the class is applicable
to all power meters that collect SML data.
2024-06-26 20:51:56 +02:00
Bernhard Kirchen
6e44a6d750 powermeter refactor: allow destruction of httpClient
make sure the wifiClient used by the httpClient lives longer than the
httpClient, as it accesses the pointer to the wifiClient in its
destructor.
2024-06-26 20:51:56 +02:00
Bernhard Kirchen
54c04aed61 SDM power meter: remove baud rate setting
this setting was not used. the baud rate for the SDM is set to 9600 in
the source code. until the baud rate being customizable is actually
required by somebody, we remove the setting altogether.
2024-06-26 20:51:56 +02:00
Bernhard Kirchen
d99cfd5b31 powermeter refactor: publish values to MQTT in base class
"powertotal" is always published and it is published by the base class
directly. other values are still published by the derived classes, but
use a base class method, which takes care that a common base topic is
used in particular.
2024-06-26 20:51:56 +02:00
Bernhard Kirchen
9eb4f1714c powermeter refactor: make timestamp of last update atomic
the timestamp is potentially updated from a different thread, e.g., MQTT
task, than the main loop, which typically reads that timestamp.
2024-06-26 20:51:56 +02:00
Bernhard Kirchen
d4c07836d9 MQTT powermeter: avoid iterating subscriptions
instead of iterating a map with subscriptions, we now bind the target
variable to the callback, which is executed once a message is arrived.
this way, the target variable is already linked to the respective topic
when the callback is executed.

lock the mutex when writing the variable, as the MQTT callback is
executed in a different context (MQTT task) than the main loop task,
which otherwise accesses the variables.
2024-06-26 20:51:56 +02:00
Bernhard Kirchen
5cd6334880 powermeter refactor: avoid reboot on settings change
the current power meter provider will be de-initialized, and a new
instance will be initialized with the new settings.
2024-06-26 20:51:56 +02:00
Bernhard Kirchen
33683d26c8 powermeter refactor: rename providers in enum
the enum values did not change, but their name (only relevant in the
code) are now more expressive.
2024-06-26 20:51:56 +02:00
Bernhard Kirchen
2397e5cdf5 powermeter refactor: split providers into their own classes
it is important to separate the capabilities of each power meter
provider into their own class/source file, as the providers work
fundamentally different and their implementations must not be
intermangled, which made maintenance and improvements a nightmare
in the past.
2024-06-26 20:51:54 +02:00
Marvin Carstensen
8ec1695d1b Feature: support Tibber bridge as power meter interface 2024-06-26 20:50:50 +02:00
Bernhard Kirchen
83c59d7811 convert files with CRLF endings to LF endings
this only changes line endings. inspect this commit with command `git
show <commit-sha> --ignore-space-at-eol` and it will tell you that the
commit appears to be "empty" (since all changes are whitespace changes
near the end of a line, which are ignored in that git show command).

the files to be changed were found and updated using this command:
find lib src include webapp/src -type f | \
    xargs grep --binary-files=without-match --files-with-matches \
    $(printf '\r\n') | xargs dos2unix

the following files were restored afterwards, as they are using CRLF
line endings in the upstream as well:
 - lib/CMT2300a/cmt2300a_defs.h
 - lib/README
 - include/README
2024-06-24 21:57:12 +02:00
Bernhard Kirchen
2cc086335f BREAKING CHANGE: repartition: double sketch size
this updates the partition scheme for devices with 4 MB of flash memory
to have only a single app partition, doubling its size, but sacrificing
their OTA update capability. the replacement environment for
"generic_esop32" is called "generic_esp32_4mb_no_ota".

the new default partition scheme is targeted for devices with at least 8
MB of flash memory. the previous two app partitions are merged into one,
and one additional app partition of the same new size is added to the
back of the table. the change preserves the littlefs partition (position
and size), allowing for upgrades without loosing the configuration.

another new environment is added, called "generic_esp32_8mb", which uses
the new default partition layout.

environment "generic" is removed. it was merely a variant of
"generic_esp32" with some pins pre-defined. we want users to install a
pin_mapping.json and use the generic firmwares.

environments for boards that have no version with at least 8 MB of flash
memory are setup using the 4 MB partition layout (no OTA updates).

all users must flash the factory.bin for their respective environment
using esptool (or compatible software) using the USB port of their
board. in other words: updating to the new partition scheme using an OTA
update is NOT possible.

hint: the ESP32-S3 builds have a smaller code footprint. this means
ESP32-S3 boards can be updated using OTA without updating the partition
layout on the devices for some unspecified time longer, i.e., until
their firmware binary actually becomes too large for the old sketch
partition size.

the non-factory binary for generic_esp32_4mb_no_ota is NOT collected as
an artifact. going forward, users must update using the factory binary
and using the USB connection to their boards.
2024-06-24 21:39:31 +02:00
Andreas Böhm
79214d750f
refactor PylontechCanBattery to be more generic (#1064) 2024-06-23 19:42:04 +02:00
Bernhard Kirchen
cb0f8f20a8 disable CI builds for generic and generic_esp32
these fail due to the overflowing sketch partition. we can re-enable CI
build for these environments once we decided on how to handle ESP32 with
only 4MB of flash.
2024-06-23 13:21:28 +02:00
Bernhard Kirchen
f21f58c67d adjust MessageOutput for changes in espressif/arduino-esp32
the "serial console" over USB would be garbled badly after switching to
"platform = espressif32@6.7.0". this did not happen to the upstream
version of MessageOutput. we used Serial.flush(), which seemed to be
good in the respective context. however, the changes in

github.com/espressif/arduino-esp32/pull/9462

made flush() detrimental. we remove the use of flush(), as it seems not
to be required (in particular, the upstream project does not use it).
2024-06-21 16:57:17 +02:00
Bernhard Kirchen
034026f782 restore JK BMS dummy implementation
broke in be41e6b9. was unusable as the complete type of DummySerial has
to be available in the JK BMS controller header when defining the
unique_ptr managing the dummy instance. this problem is solved by moving
the whole dummy class into its own header.
2024-06-21 16:57:11 +02:00
Bernhard Kirchen
5e3a53d8d3 Merge upstream tag 'v24.6.10' into development 2024-06-21 16:45:41 +02:00
Andreas Böhm
83ac15405e
Feature: Implement DPL 'overscaling' to compensate shading (#956) 2024-06-20 13:32:29 +02:00
cerise21
ccbaf55808
Feature: Set/obtain DPL target power consumption via MQTT 2024-06-20 13:25:41 +02:00
Bernhard Kirchen
95e560bdc7 fix: optimize margins in live view
all total cards at the top of the live view go into the same row.
bootstrap will line-break after every third column/card, as the row
is row-cols-3.

the battery icon to the right of the project name in the header shall
have marging to said project name.

the rows in the live view now use class mt-0 to counteract bootstraps
negative margin for individual rows.
2024-06-17 17:32:26 +02:00
cerise21
1f6fdb7fc0
Feature: Set/obtain DPL upper power limit via MQTT 2024-06-15 20:21:42 +02:00
Thomas Basler
c144b68306 webapp: add app.js.gz 2024-06-10 21:45:56 +02:00
Thomas Basler
119b7b18e6 Upgrade ESP Async WebServer from 2.10.6 to 2.10.8 2024-06-10 21:44:33 +02:00
Thomas Basler
417df65b92 webapp: update dependencies 2024-06-10 21:40:55 +02:00
Thomas Basler
a2b568923c Upgrade ESP Async WebServer from 2.10.5 to 2.10.6 2024-06-09 14:54:03 +02:00
Thomas Basler
b5398a4297 Changed issue template to make clear that issues are bugs that affect all users 2024-06-08 12:39:04 +02:00
Thomas Basler
c960602c62 Upgrade ESP Async WebServer from 2.10.3 to 2.10.5 2024-06-08 11:16:06 +02:00
Thomas Basler
8ef28e27b4 webapp: update dependencies 2024-06-08 11:11:31 +02:00
Bernhard Kirchen
5a007e5352 fix: make SDM power meter use serial port manager
instead of hard-coding the use of hardware UART 2, the SDM power meter
instance now asks for a free hardware serial port to use and
instanciates the respective HardwareSerial object using said port.
2024-06-02 22:41:07 +02:00
Bernhard Kirchen
be41e6b906 refactor serial port manager: hand out UARTs FCFS
get rid of particular compile-time designations by UART index. just hand
out the next free index of hardware UARTs, or indicate that none is
available any more.

use names as keys to register and free UARTs.
2024-06-02 22:41:07 +02:00
Bernhard Kirchen
5a1c3af31f Feature: add support for a third Victron MPPT
only on ESP32-S3-USB. this fiddles with the available hardware UARTs to
make it possible to use a third Victron MPPT. if three MPPTs are defined
int the pin mapping, you will not be able to use the SmartShunt and JK
BMS battery interfaces.

note that using a second MPPT will also conflict with the SDM power
meter, and that conflict is not detected, yet.
2024-06-02 22:41:07 +02:00
Thomas Basler
b2515753c1 Upgrade ESP Async WebServer from 2.10.0 to 2.10.3 2024-06-02 14:13:32 +02:00
Thomas Basler
b1a8f04617 Fix: Wrong divider in gridprofile RVHF
Fixes #2021
The result may look wrong for some profiles (e.g. 502 Hz) but it seems to be correct as the Hoymiles parser also outputs 502 Hz. See #1606
2024-06-02 13:56:13 +02:00
Thomas Basler
ea54397cfc Merge branch 'pr2025' into dev 2024-06-02 13:44:32 +02:00
Bernhard Kirchen
7548fceb48 check FW bin file size when creating factory.bin 2024-06-02 13:28:10 +02:00
Bernhard Kirchen
90aafe2cbf check FW bin file size when creating factory.bin 2024-06-01 22:19:58 +02:00
Bernhard Kirchen
c22ae2bf8d Feature: show BMS FW and HW version (JK BMS, SmartShunt) 2024-06-01 11:23:22 +02:00
swingstate
561f4be6d6 Feature: SmartShunt: process midpoint voltage and deviation 2024-05-31 21:08:15 +02:00
Bernhard Kirchen
63370e8a83 VE.Direct: prefer strncpy over strcpy
strcpy is not safe.
2024-05-31 20:16:29 +02:00
Bernhard Kirchen
88314f93c2 Fix: properly format Victron MPPT firmware version 2024-05-31 20:16:29 +02:00
Thomas Basler
cffa7a2b2c Remove no more required async_tcp patch 2024-05-31 01:01:47 +02:00
Thomas Basler
b27a476507 Fix: Apply inverter settings only once and not for each channel 2024-05-31 00:56:15 +02:00