Commit Graph

555 Commits

Author SHA1 Message Date
Eugen
2637e32145
Feature: rxen/txen support for RS485 transceiver for SDM power meter (#1269)
This allows to talk to the SDM power meter through an RS485 transceiver
with separate rxen and txen pins, like on the OpenDTU Fusion board.
2024-09-23 21:20:03 +02:00
Bernhard Kirchen
38726b99ab Merge remote-tracking branch 'tbnobody/master' into development 2024-09-21 22:00:49 +02:00
Thomas Basler
3b3e6995c2 Fix: WebApp was not reloaded after firmware update
With the upgrade from ESPAsyncWebServer to 3.3.1 it seems that something has changed. Have to trigger the reboot from the main context.
2024-09-21 00:04:27 +02:00
Snoopy-HSS
3fc43098a6
Feature: Support for SBS Unipower batteries (#1199)
Allows to connect to SBS Unipower batteries using a CAN bus.
2024-09-16 15:22:15 +02:00
Andreas Böhm
a6e7007f4b
Feature: extend battery discharge limit support (#1245)
* implements UI to configure battery discharge limit
* adds support for discharge limit to MQTT battery provider
* add option to hide `issues` section from battery live view (for MQTT battery)
2024-09-13 20:52:23 +02:00
ranma
6318ab4a8b
Feature: DPL: Honor battery-provided discharge power limit (#1198)
When the BMS provides a discharge current limit, apply
this limit in the DPL to the inverter power target when running
from battery.
2024-09-13 20:36:16 +02:00
Andreas Böhm
c96762c765
Fix: don't republish MQTT powermeter data to MQTT (#1250) 2024-09-13 17:26:30 +02:00
Gumbagubanga
89d9a40296
Feature: Support for W5500 ethernet module (#1231)
adds support for w5500 Ethernet chip, present on
OpenDTU Fusion PoE Ethernet hat in particular.
2024-09-13 16:51:22 +02:00
ranma
f42f018f3e
Fix: sanitize battery manufacturer name string (#1235)
If the string contains control characters for some reason, the browser
will reject the json with the error `bad control character in string
literal`.

This adds a setManufacturer function that validates the string is ASCII
and will cut off the string at the first non-ascii character.

Pylontech: `PYLON` (50 59 4C 4F 4E 20 20 20)
Pytes: `PYTES` (50 59 54 45 53)
Deye: `DY001` (44 59 30 30 31 03 E8 03)

See https://github.com/helgeerbe/OpenDTU-OnBattery/discussions/1226#discussioncomment-10566898
2024-09-09 21:46:47 +02:00
Thomas Basler
b52cd31309 Output WiFi disconnect reason in console 2024-09-02 20:16:03 +02:00
ranma
a87f9fa2cd
Fix: Allow higher-resolution SoC in live view header (#1197)
Commit accc70dea0 added the battery SoC to
the live view header. But due to getSoC() returning an int,
the precision was limited.

This changes getSoC() to return float so when a source with higher
precision is available, the respective precision is shown.
2024-09-02 11:08:21 +02:00
Bernhard Kirchen
babb24ab1f Fix: reasonable full solar-passthrough default values
value 100 is not accepted by the webapp as inputs for full
solar-passthrough start and stop volages. 66V is the documented
value to be used if one wants to disable full solar-passthrough
(while keeping (non-full) solar-passthrough).
2024-09-01 22:12:48 +02:00
Bernhard Kirchen
fff0576150 Fix: initialize HTTP(S)+JSON power meter values 2024-08-28 13:32:47 +02:00
Bernhard Kirchen
1cbf18d4a7 Feature: HttpGetter: cache digest challenge
this allows us to add a valid Authorization header to each but the first
GET request, saving us from performing two GET requests every time we
want to perform the GET request. we still need a new client nonce and we
need to increase the nonce counter, so we also need to calculate a whole
new response, as we cannot just reuse the previous Authorization header
(that would be a replay attack).
2024-08-28 13:32:47 +02:00
Bernhard Kirchen
fd3b65f4bd Feature: HttpGetter: support MD5 digest authentication
the MD5 scheme should still be widely deployed, even though it is
deprecated. it is also still the default if not specific algorithm
is requested by the server.
2024-08-28 13:32:47 +02:00
Bernhard Kirchen
63612e9276 Fix: restart TCP connection if HTTP server sends Connection:close
we previously performed a whole new GET request when doing digest
authentication. it seemed beneficial to reuse the TCP connection to
perform the second GET request, which includes the authentication
tokens. however, if the server sends "Connection: close" we must not
requse the TCP connection for another HTTP request.

this broke authentication against Shelly devices (at least those with
original firmware).

now we explicitly set "Connection: keep-alive" in our request, and reuse
the TCP connection only if te server replies with "Connection:
keep-alive" as well.
2024-08-28 13:32:47 +02:00
Andreas Böhm
65407dbdd6
fix: update mqtt subscriptions when topic changed (#1156)
* update mqtt subscriptions when topic was changed
* DPL/Huawei: manage MQTT subscriptions in map

---------

Co-authored-by: Bernhard Kirchen <schlimmchen@posteo.net>
2024-08-20 23:44:27 +02:00
Andreas Böhm
df53f34b51
Feature: SPIPortManager allows simultaneous use of CMT2300 and Huawei charger
* backport SPIPortManager from @skippermeister
* adapt to support ESP32 and ESP32-S3 and ESP32-C3
* use logic to work with SPI numbering as in the official
  documentation: start with SPI0 and go up to SPI3
* increase Huawei CAN controller stack size to 2000
* increase startup delay for USB_CDC enabled builds to be able to
  catch bootlogs over USB
2024-08-19 20:44:59 +02:00
Bernhard Kirchen
5d1d071c8a
Fix: Improve DPL nighttime discharging (#1126)
* fix: DPL: start discharging at night logic error

the switch "always start discharging battery at night" would cause to
stop discharging the battery when there was solar power and the battery
was discharged below the start threshold.

this change introduces a nighttime discharging boolean variable, which
is enabled the instant we decide to start a battery discharge cycle due
to nighttime havin arrived. we reset this variable as soon as it is
daytime (solar power available). in that case, we allow discharging the
battery if the start threshold was reached. this can actually be the
case if the battery is charged with cheap electricity during the night.

removed comments as they merely spell out what the if statement already
expresses quite nicely.

* use SunPosition.isDayPeriod() to check for daytime

---------

Co-authored-by: Andreas Böhm <andreas@boehm.cx>
2024-08-15 20:10:32 +02:00
Bernhard Kirchen
04513d3f22 webapp: disable OTA firmware dialog for unsupported devices
show a warning instead and cancel uploads with a HTPP 500 response.
2024-08-04 22:38:19 +02:00
Thomas Basler
70dacb5ea6 Merge branch 'pr2168' into dev 2024-08-01 17:53:53 +02:00
vaterlangen
cb5e7e59a5 Feature: add unit for MQTT battery voltage (#1143) 2024-07-31 15:05:41 +02:00
Bernhard Kirchen
1a19f881aa Feature: support JSON payload in MQTT battery provider
this changeset adds support for parsing the MQTT battery provider's SoC
and voltage topics' payloads as JSON to extract a numeric value at a
configurable path.
2024-07-31 15:05:41 +02:00
Andreas Böhm
accc70dea0
feature: show battery voltage, current, and power in live view (#1131)
* show battery voltage, current, and power in live view header (the "totals")
* show battery current and power in extra card
* use soc and current precision in live view
* BatteryStats: do not knowingly publish invalid data: not all battery
  providers know all values the base class manages. make sure to
  prevent publishing invalid values.

Co-authored-by: Bernhard Kirchen <schlimmchen@posteo.net>
2024-07-27 21:35:58 +02:00
Andreas Böhm
e95b70efeb
Feature: expose 'full solar passsthrough active' via MQTT (#1136) 2024-07-26 20:37:40 +02:00
Andreas Böhm
e3f9da75b9
BREAKING CHANGE: allow multiple OpenDTU-OnBattery instances at same HASS
This breaks existing HASS automation, as entity names and MQTT topics change!

* include dtu-unique-id in DPL MQTT HASS topics to allow multiple DTUs to be controlled
* fix filename "src/MqttHandlVedirectHass.cpp"
* refactor: use values from 'MqttHandleHass', add 'via_device' to all HASS devices
* set step size for power limiter voltage values
2024-07-23 21:27:14 +02:00
Bernhard Kirchen
6ee6eaf0b2
Fix: inverter power limits precision
Hoymiles inverters allow setting relative limits with a precision of 0.1 %.
this changeset allows to utilize this precision.

* preserve accuracy when decoding power limit
* Web API: process floating point limits
* MQTT: process floating point limits
* use appropriate accuracy for limits in web UI
* HASS: step for relative inverter limit is 0.1 %
2024-07-23 21:17:25 +02:00
Bernhard Kirchen
d9d0141fde Merge upstream tag 'v24.6.29' into development 2024-07-10 21:45:43 +02:00
Bernhard Kirchen
e358513495
Merge PR #1077 from helgeerbe/powermeter-refactoring
this PowerMeter refactoring tackles many issues and prepares to solve many more.
2024-07-10 21:20:39 +02:00
Andreas Böhm
6a3f90ff95
Feature: add support for Pytes batteries using CAN (#1088)
Co-authored-by: Bernhard Kirchen <schlimmchen@posteo.net>
2024-07-10 21:01:49 +02:00
Bernhard Kirchen
0c16652acb make MQTT power meter the default power meter
make the MQTT power meter pre-selected when editing power meter settings
for the first time. the MQTT power meter is the most efficient and hence
preferred power meter implementation.
2024-07-01 22:12:30 +02:00
Thomas Basler
4640ddfba0 Better handling of empty MQTT client id
If the configured client id is empty, the default value (auto generated) will be used
2024-06-29 11:05:04 +02:00
Thomas Basler
ba95f99e03 Feature: Allow custom MQTT Client ID 2024-06-29 00:28:21 +02:00
Thomas Basler
b9b2a19ac5 Fix: Remove not required semicolon 2024-06-29 00:08:27 +02:00
Bernhard Kirchen
6b19b877c6 power meter refactoring: split loop task init from init()
when performing a test request using the web UI, we need to init() the
respective power meter, but we do not want to start the polling task.
hence we move initialization of the polling task to the poll() function.
it will return if the task is setup already, otherwise setup the task.
2024-06-27 22:18:41 +02:00
Bernhard Kirchen
6b09ca056e Feature: SML power meters: reset SML decoder
implement a function which allows to reset the SML decoder. this new
function is used after a datagram ends. for the SML HTTP power meter
this is simple: after all bytes from the request's answer have been
decoded, we reset the decoder. for the SML serial power meter, we
perform the reset after a datagram ended based on timing (no new bytes
have been received for a specific amount of time).
2024-06-27 22:18:41 +02:00
Bernhard Kirchen
ea454972b9 Feature: SML power meter: handle checksum error
cache the values decoded in the SML datagram and only copy them to the
local stash of values if the checksum of the SML datagram matched. also
makes sure that values from incomplete SML datagrams are not used.

moreover, we now only publish values to the MQTT broker that we actually
decoded (successfully) from an SML datagram (we previously published 0.0
as values to topics we never decoded a value for).
2024-06-27 22:18:41 +02:00
Bernhard Kirchen
a1138a2202 Feature: Serial SML power meter: poll asynchronously 2024-06-27 22:18:41 +02:00
Bernhard Kirchen
fb7b710cb7 SML power meter: improve message output
* when printing a message, tell the name of the derived class.
* print total power only when state SML_FINAL reached.
* tell if a checksum verification error occurred.
2024-06-27 22:18:41 +02:00
Bernhard Kirchen
6c06e71fd0 Feature: SDM power meter: switch to software serial
a 9600 baud serial interface does not need a hardware UART. these
changes switch the SDM power meter implementation to use a software
serial instance instead. this is desirable as hardware UARTs are scarce
and users need them for JK BMS and VE.Direct interfaces.
2024-06-27 22:18:41 +02:00
Bernhard Kirchen
a5ba24fdd8 SDM power meter: check stop flag in between transactions
the destructor will block for way too long if we keep holding the
polling mutex while performing a transcation with the SDM power meter.
when reading, we now release the lock. afterwards, i.e., in between
transactions, we check the stop flag so the task terminates in a timely
manner once asked to do so.
2024-06-27 22:18:41 +02:00
Bernhard Kirchen
40423b0e07 SDM power meter: evaluate error code after polling value 2024-06-27 22:18:41 +02:00
Bernhard Kirchen
15b6a32b92 Feature: support JSON payload in MQTT power meter
the MQTT power meter can now process the messages published at the
respective topics as JSON and extract a power value using a JSON path
(same as in HTTP+JSON power meter). additionally, selecting a unit for
the power value as well as an option to invert the value's sign was
added as well, similar to the HTTPS+JSON power meter.
2024-06-27 22:18:41 +02:00
Bernhard Kirchen
347dd67684 Feature: SDM power meter: poll asynchronously 2024-06-27 22:18:41 +02:00
Bernhard Kirchen
8a46ba9541 Feature: HTTP+JSON power meter: poll asynchronously 2024-06-27 22:18:41 +02:00
Bernhard Kirchen
f6f62a604d Feature: HTTP+SML power meter: poll asynchronously 2024-06-27 22:18:41 +02:00
Bernhard Kirchen
a2a9debd02 Feature: make power meter polling intervals configurable
this change makes the respective setting accessible from the web UI.
2024-06-27 22:18:41 +02:00
Bernhard Kirchen
b891a4c1a3 powermeter refactor: instanciate power meters with config
instead of reading the main config's powermeter struct(s), the
individual power meters now are instanciated using a copy of their
respective config. this allows to instanciate different power meters
with different configs. as a first step, this simplifies instanciating
power meters for test purposes.
2024-06-27 22:18:41 +02:00
Bernhard Kirchen
3f2d9d38fa powermeter refactor: fully structure settings per provider
all power meter providers now have their own configuration struct
defined. a respective method to serialize and deserialize the provider
config is implemented for each provider.
2024-06-27 22:18:41 +02:00
Bernhard Kirchen
e1778eba76 powermeter refactor: use HttpGetter in HTTP SML implementation 2024-06-27 22:18:41 +02:00