Repository navigation
feat(hoymiles): early RX exit for faster inverter control - #3225
Conversation
|
@tbnobody @schlimmchen FYI. I know several people using OpenDTU for power limit control through Home Assistant. I've read the github history, why these timeouts were set high. No objection to that. I hope this PR will make in. That's a very good improvements in OpenDTU reactivity! Note: a good thing of this PR is that MQTT validation could be dropped to 1 or 2 seconds in order for Home Assistant to get the feedback about the invert stats updates faster also. |
6c045a0 to
11aa4a6
Compare
Add a Zero-Export module that regulates Hoymiles inverter power limits based on grid power received from Shelly Local Network Messaging. Shelly LNM sends grid measurements through UDP multicast, avoiding periodic HTTP polling. OpenDTU listens with WiFiUDP and processes incoming datagrams from the scheduler without blocking inverter communication or introducing additional request/response traffic. The module provides: - Enable/disable configuration - Grid power setpoint - Minimum production power - Configurable regulation interval - Shelly LNM multicast address and port - Balanced power-limit distribution across inverters - Handling for temporarily unreachable inverters - Web API endpoints - Home Assistant MQTT switch, setpoint, and status entities - Zero-Export settings page in the web interface The default regulation interval is 30 seconds. This allows HMS inverters approximately 1-2 seconds to apply a new power limit and gives Shelly LNM time to measure and propagate the updated grid value. Once PR tbnobody#3225 is merged, communication will become immediate and up to 10 inverters can be updated within approximately 2 seconds. The regulation interval can then safely be reduced to the 5-second minimum.
Add a Zero-Export module that regulates Hoymiles inverter power limits based on grid power received from Shelly Local Network Messaging. Shelly LNM sends grid measurements through UDP multicast, avoiding periodic HTTP polling. OpenDTU listens with WiFiUDP and processes incoming datagrams from the scheduler without blocking inverter communication or introducing additional request/response traffic. The module provides: - Enable/disable configuration - Grid power setpoint - Minimum production power - Configurable regulation interval - Shelly LNM multicast address and port - Balanced power-limit distribution across inverters - Handling for temporarily unreachable inverters - Web API endpoints - Home Assistant MQTT switch, setpoint, and status entities - Zero-Export settings page in the web interface The default regulation interval is 30 seconds. This allows HMS inverters approximately 1-2 seconds to apply a new power limit and gives Shelly LNM time to measure and propagate the updated grid value. Once PR tbnobody#3225 is merged, communication will become immediate and up to 10 inverters can be updated within approximately 2 seconds. The regulation interval can then safely be reduced to the 5-second minimum.
Add a Zero-Export module that regulates Hoymiles inverter power limits based on grid power received from Shelly Local Network Messaging. Shelly LNM sends grid measurements through UDP multicast, avoiding periodic HTTP polling. OpenDTU listens with WiFiUDP and processes incoming datagrams from the scheduler without blocking inverter communication or introducing additional request/response traffic. The module provides: - Enable/disable configuration - Grid power setpoint - Minimum production power - Configurable regulation interval - Shelly LNM multicast address and port - Balanced power-limit distribution across inverters - Handling for temporarily unreachable inverters - Web API endpoints - Home Assistant MQTT switch, setpoint, and status entities - Zero-Export settings page in the web interface The default regulation interval is 30 seconds. This allows HMS inverters approximately 1-2 seconds to apply a new power limit and gives Shelly LNM time to measure and propagate the updated grid value. Once PR tbnobody#3225 is merged, communication will become immediate and up to 10 inverters can be updated within approximately 2 seconds. The regulation interval can then safely be reduced to the 5-second minimum.
Add a Zero-Export module that regulates Hoymiles inverter power limits based on grid power received from Shelly Local Network Messaging. Shelly LNM sends grid measurements through UDP multicast, avoiding periodic HTTP polling. OpenDTU listens with WiFiUDP and processes incoming datagrams from the scheduler without blocking inverter communication or introducing additional request/response traffic. The module provides: - Enable/disable configuration - Grid power setpoint - Minimum production power - Configurable regulation interval - Shelly LNM multicast address and port - Balanced power-limit distribution across inverters - Handling for temporarily unreachable inverters - Web API endpoints - Home Assistant MQTT switch, setpoint, and status entities - Zero-Export settings page in the web interface The default regulation interval is 30 seconds. This allows HMS inverters approximately 1-2 seconds to apply a new power limit and gives Shelly LNM time to measure and propagate the updated grid value. Once PR tbnobody#3225 is merged, communication will become immediate and up to 10 inverters can be updated within approximately 2 seconds. The regulation interval can then safely be reduced to the 5-second minimum.
Add a Zero-Export module that regulates Hoymiles inverter power limits based on grid power received from Shelly Local Network Messaging. Shelly LNM sends grid measurements through UDP multicast, avoiding periodic HTTP polling. OpenDTU listens with WiFiUDP and processes incoming datagrams from the scheduler without blocking inverter communication or introducing additional request/response traffic. The module provides: - Enable/disable configuration - Grid power setpoint - Minimum production power - Configurable regulation interval - Shelly LNM multicast address and port - Balanced power-limit distribution across inverters - Handling for temporarily unreachable inverters - Web API endpoints - Home Assistant MQTT switch, setpoint, and status entities - Zero-Export settings page in the web interface The default regulation interval is 30 seconds. This allows HMS inverters approximately 1-2 seconds to apply a new power limit and gives Shelly LNM time to measure and propagate the updated grid value. Once PR tbnobody#3225 is merged, communication will become immediate and up to 10 inverters can be updated within approximately 2 seconds. The regulation interval can then safely be reduced to the 5-second minimum.
Add a Zero-Export module that regulates Hoymiles inverter power limits based on grid power received from Shelly Local Network Messaging. Shelly LNM sends grid measurements through UDP multicast, avoiding periodic HTTP polling. OpenDTU listens with WiFiUDP and processes incoming datagrams from the scheduler without blocking inverter communication or introducing additional request/response traffic. The module provides: - Enable/disable configuration - Grid power setpoint - Minimum production power - Configurable regulation interval - Shelly LNM multicast address and port - Balanced power-limit distribution across inverters - Handling for temporarily unreachable inverters - Web API endpoints - Home Assistant MQTT switch, setpoint, and status entities - Zero-Export settings page in the web interface The default regulation interval is 30 seconds. This allows HMS inverters approximately 1-2 seconds to apply a new power limit and gives Shelly LNM time to measure and propagate the updated grid value. Once PR tbnobody#3225 is merged, communication will become immediate and up to 10 inverters can be updated within approximately 2 seconds. The regulation interval can then safely be reduced to the 5-second minimum.
Add a Zero-Export module that regulates Hoymiles inverter power limits based on grid power received from Shelly Local Network Messaging. Shelly LNM sends grid measurements through UDP multicast, avoiding periodic HTTP polling. OpenDTU listens with WiFiUDP and processes incoming datagrams from the scheduler without blocking inverter communication or introducing additional request/response traffic. The module provides: - Enable/disable configuration - Grid power setpoint - Minimum production power - Configurable regulation interval - Shelly LNM multicast address and port - Balanced power-limit distribution across inverters - Handling for temporarily unreachable inverters - Web API endpoints - Home Assistant MQTT switch, setpoint, and status entities - Zero-Export settings page in the web interface The default regulation interval is 30 seconds. This allows HMS inverters approximately 1-2 seconds to apply a new power limit and gives Shelly LNM time to measure and propagate the updated grid value. Once PR tbnobody#3225 is merged, communication will become immediate and up to 10 inverters can be updated within approximately 2 seconds. The regulation interval can then safely be reduced to the 5-second minimum.
Add a Zero-Export module that regulates Hoymiles inverter power limits based on grid power received from Shelly Local Network Messaging. Shelly LNM sends grid measurements through UDP multicast, avoiding periodic HTTP polling. OpenDTU listens with WiFiUDP and processes incoming datagrams from the scheduler without blocking inverter communication or introducing additional request/response traffic. The module provides: - Enable/disable configuration - Grid power setpoint - Minimum production power - Configurable regulation interval - Shelly LNM multicast address and port - Balanced power-limit distribution across inverters - Handling for temporarily unreachable inverters - Web API endpoints - Home Assistant MQTT switch, setpoint, and status entities - Zero-Export settings page in the web interface The default regulation interval is 30 seconds. This allows HMS inverters approximately 1-2 seconds to apply a new power limit and gives Shelly LNM time to measure and propagate the updated grid value. Once PR tbnobody#3225 is merged, communication will become immediate and up to 10 inverters can be updated within approximately 2 seconds. The regulation interval can then safely be reduced to the 5-second minimum.
|
converted to draft - I saw this morning that all inverters were unreachable in OpenDTU. Checking what could cause that. |
11aa4a6 to
8bcf62c
Compare
Add a Zero-Export module that regulates Hoymiles inverter power limits based on grid power received from Shelly Local Network Messaging. Shelly LNM sends grid measurements through UDP multicast, avoiding periodic HTTP polling. OpenDTU listens with WiFiUDP and processes incoming datagrams from the scheduler without blocking inverter communication or introducing additional request/response traffic. The module provides: - Enable/disable configuration - Grid power setpoint - Minimum production power - Configurable regulation interval - Shelly LNM multicast address and port - Balanced power-limit distribution across inverters - Handling for temporarily unreachable inverters - Web API endpoints - Home Assistant MQTT switch, setpoint, and status entities - Zero-Export settings page in the web interface The default regulation interval is 30 seconds. This allows HMS inverters approximately 1-2 seconds to apply a new power limit and gives Shelly LNM time to measure and propagate the updated grid value. Once PR tbnobody#3225 is merged, communication will become immediate and up to 10 inverters can be updated within approximately 2 seconds. The regulation interval can then safely be reduced to the 5-second minimum.
Add a Zero-Export module that regulates Hoymiles inverter power limits based on grid power received from Shelly Local Network Messaging. Shelly LNM sends grid measurements through UDP multicast, avoiding periodic HTTP polling. OpenDTU listens with WiFiUDP and processes incoming datagrams from the scheduler without blocking inverter communication or introducing additional request/response traffic. The module provides: - Enable/disable configuration - Grid power setpoint - Minimum production power - Configurable regulation interval - Shelly LNM multicast address and port - Balanced power-limit distribution across inverters - Handling for temporarily unreachable inverters - Web API endpoints - Home Assistant MQTT switch, setpoint, and status entities - Zero-Export settings page in the web interface The default regulation interval is 30 seconds. This allows HMS inverters approximately 1-2 seconds to apply a new power limit and gives Shelly LNM time to measure and propagate the updated grid value. Once PR tbnobody#3225 is merged, communication will become immediate and up to 10 inverters can be updated within approximately 2 seconds. The regulation interval can then safely be reduced to the 5-second minimum.
Add a Zero-Export module that regulates Hoymiles inverter power limits based on grid power received from Shelly Local Network Messaging. Shelly LNM sends grid measurements through UDP multicast, avoiding periodic HTTP polling. OpenDTU listens with WiFiUDP and processes incoming datagrams from the scheduler without blocking inverter communication or introducing additional request/response traffic. The module provides: - Enable/disable configuration - Grid power setpoint - Minimum production power - Configurable regulation interval - Shelly LNM multicast address and port - Balanced power-limit distribution across inverters - Handling for temporarily unreachable inverters - Web API endpoints - Home Assistant MQTT switch, setpoint, and status entities - Zero-Export settings page in the web interface The default regulation interval is 30 seconds. This allows HMS inverters approximately 1-2 seconds to apply a new power limit and gives Shelly LNM time to measure and propagate the updated grid value. Once PR tbnobody#3225 is merged, communication will become immediate and up to 10 inverters can be updated within approximately 2 seconds. The regulation interval can then safely be reduced to the 5-second minimum.
8bcf62c to
29a1223
Compare
Add a Zero-Export module that regulates Hoymiles inverter power limits based on grid power received from Shelly Local Network Messaging. Shelly LNM sends grid measurements through UDP multicast, avoiding periodic HTTP polling. OpenDTU listens with WiFiUDP and processes incoming datagrams from the scheduler without blocking inverter communication or introducing additional request/response traffic. The module provides: - Enable/disable configuration - Grid power setpoint - Minimum production power - Configurable regulation interval - Shelly LNM multicast address and port - Balanced power-limit distribution across inverters - Handling for temporarily unreachable inverters - Web API endpoints - Home Assistant MQTT switch, setpoint, and status entities - Zero-Export settings page in the web interface The default regulation interval is 30 seconds. This allows HMS inverters approximately 1-2 seconds to apply a new power limit and gives Shelly LNM time to measure and propagate the updated grid value. Once PR tbnobody#3225 is merged, communication will become immediate and up to 10 inverters can be updated within approximately 2 seconds. The regulation interval can then safely be reduced to the 5-second minimum.
Add a Zero-Export module that regulates Hoymiles inverter power limits based on grid power received from Shelly Local Network Messaging. Shelly LNM sends grid measurements through UDP multicast, avoiding periodic HTTP polling. OpenDTU listens with WiFiUDP and processes incoming datagrams from the scheduler without blocking inverter communication or introducing additional request/response traffic. The module provides: - Enable/disable configuration - Grid power setpoint - Minimum production power - Configurable regulation interval - Shelly LNM multicast address and port - Balanced power-limit distribution across inverters - Handling for temporarily unreachable inverters - Web API endpoints - Home Assistant MQTT switch, setpoint, and status entities - Zero-Export settings page in the web interface The default regulation interval is 30 seconds. This allows HMS inverters approximately 1-2 seconds to apply a new power limit and gives Shelly LNM time to measure and propagate the updated grid value. Once PR tbnobody#3225 is merged, communication will become immediate and up to 10 inverters can be updated within approximately 2 seconds. The regulation interval can then safely be reduced to the 5-second minimum.
|
I completed some testing thanks to PR #3227. Regulation before this fix:
With 8 inverters this is not possible top improve more. After this fix:
Queue is drained quickly and power control are sent within 2 sec. |
Add a Zero-Export module that regulates Hoymiles inverter power limits based on grid power received from Shelly Local Network Messaging. Shelly LNM sends grid measurements through UDP multicast, avoiding periodic HTTP polling. OpenDTU listens with WiFiUDP and processes incoming datagrams from the scheduler without blocking inverter communication or introducing additional request/response traffic. The module provides: - Enable/disable configuration - Grid power setpoint - Minimum production power - Configurable regulation interval - Shelly LNM multicast address and port - Balanced power-limit distribution across inverters - Handling for temporarily unreachable inverters - Web API endpoints - Home Assistant MQTT switch, setpoint, and status entities - Zero-Export settings page in the web interface The default regulation interval is 30 seconds. This allows HMS inverters approximately 1-2 seconds to apply a new power limit and gives Shelly LNM time to measure and propagate the updated grid value. Once PR tbnobody#3225 is merged, communication will become immediate and up to 10 inverters can be updated within approximately 2 seconds. The regulation interval can then safely be reduced to the 5-second minimum.
…d sources Add a Zero-Export module that regulates Hoymiles inverter power limits based on grid power received from a configurable grid source. Two sources are currently available: - Shelly LNM (Local Network Messaging): Shelly meters stream LNM status messages through UDP multicast, avoiding periodic HTTP polling. OpenDTU listens with WiFiUDP and processes incoming datagrams from the scheduler without blocking inverter communication. The wire protocol is the binary "SL" header followed by a JSON payload (em1:0 / em:0 / etc.). - MQTT: any power meter publishing a plain numeric value or a JSON object with a power field (act_power / total_act_power, Shelly EM / 3EM style) can be used by subscribing to a configurable "Grid Power Topic" on the existing OpenDTU MQTT client. Retained messages are ignored so stale retained values never drive the regulation. Grid sources are modelled as a small ZeroExportGridSource interface, making it straightforward to add more sources later. The regulation loop reads the freshest grid power from the active source (with an implementation-specific freshness timeout) and distributes the needed correction proportionally to the inverters' rated power, never going below a configurable minimal production (default: 100 W per inverter). The tracked state is the set of limits the controller has requested, not the values read back from the inverters. Safety behavior: - Limits are only ever sent to reachable, command-enabled inverters. - On disable, a RelativNonPersistent 100 % release is sent, retried until all inverters have been positively released. - On DTU restart with Zero-Export disabled, a release is scheduled so limits left by a previous run are not retained on the inverters. - On DTU restart with Zero-Export enabled, each inverter starts at a 100 W power floor so that the regulation does not guess a stale value. - A keep-alive resend prevents the inverters' own non-persistent-limit timeout from silently reverting them to full power. - If no fresh grid value is available, no RF traffic is generated. The default regulation interval is 30 seconds. This allows HMS inverters approximately 1-2 seconds to apply a new power limit and gives Shelly LNM time to measure and propagate the updated grid value. Once PR tbnobody#3225 is merged, communication will become immediate and up to 10 inverters can be updated within approximately 2 seconds, which would allow reducing the regulation interval to the 5-second minimum. The settings page exposes: - Enable/disable switch - Grid power setpoint - Minimum production power - Regulation interval - Grid source dropdown (Shelly LNM / MQTT) - Shelly LNM multicast group and port - MQTT grid power topic - Live status (grid power, currently applied production limit) with a 5-second refresh Home Assistant integration (when MQTT auto-discovery is enabled) publishes a switch, a setpoint number, a grid power sensor and a production-limit sensor; the switch and setpoint can be changed from Home Assistant. Closes: #<issue>
…d sources Add a Zero-Export module that regulates Hoymiles inverter power limits based on grid power received from a configurable grid source. Two sources are currently available: - Shelly LNM (Local Network Messaging): Shelly meters stream LNM status messages through UDP multicast, avoiding periodic HTTP polling. OpenDTU listens with WiFiUDP and processes incoming datagrams from the scheduler without blocking inverter communication. The wire protocol is the binary "SL" header followed by a JSON payload (em1:0 / em:0 / etc.). - MQTT: any power meter publishing a plain numeric value or a JSON object with a power field (act_power / total_act_power, Shelly EM / 3EM style) can be used by subscribing to a configurable "Grid Power Topic" on the existing OpenDTU MQTT client. Retained messages are ignored so stale retained values never drive the regulation. Grid sources are modelled as a small ZeroExportGridSource interface, making it straightforward to add more sources later. The regulation loop reads the freshest grid power from the active source (with an implementation-specific freshness timeout) and distributes the needed correction proportionally to the inverters' rated power, never going below a configurable minimal production (default: 100 W per inverter). The tracked state is the set of limits the controller has requested, not the values read back from the inverters. Safety behavior: - Limits are only ever sent to reachable, command-enabled inverters. - On disable, a RelativNonPersistent 100 % release is sent, retried until all inverters have been positively released. - On DTU restart with Zero-Export disabled, a release is scheduled so limits left by a previous run are not retained on the inverters. - On DTU restart with Zero-Export enabled, each inverter starts at a 100 W power floor so that the regulation does not guess a stale value. - A keep-alive resend prevents the inverters' own non-persistent-limit timeout from silently reverting them to full power. - If no fresh grid value is available, no RF traffic is generated. The default regulation interval is 30 seconds. This allows HMS inverters approximately 1-2 seconds to apply a new power limit and gives Shelly LNM time to measure and propagate the updated grid value. Once PR tbnobody#3225 is merged, communication will become immediate and up to 10 inverters can be updated within approximately 2 seconds, which would allow reducing the regulation interval to the 5-second minimum. The settings page exposes: - Enable/disable switch - Grid power setpoint - Minimum production power - Regulation interval - Grid source dropdown (Shelly LNM / MQTT) - Shelly LNM multicast group and port - MQTT grid power topic - Live status (grid power, currently applied production limit) with a 5-second refresh Home Assistant integration (when MQTT auto-discovery is enabled) publishes a switch, a setpoint number, a grid power sensor and a production-limit sensor; the switch and setpoint can be changed from Home Assistant. Closes: #<issue>
…d sources Add a Zero-Export module that regulates Hoymiles inverter power limits so that the grid power stays around a configurable setpoint (default: 0 W, i.e. neither export to nor import from the grid), based on the grid power received from a configurable grid source. Two sources are currently available: - Shelly LNM (Local Network Messaging): Shelly meters stream LNM status messages through UDP multicast, avoiding periodic HTTP polling. OpenDTU listens with WiFiUDP and processes incoming datagrams from the scheduler without blocking inverter communication. The wire format is a 12-byte binary header starting with the "SL" magic followed by a JSON payload (em1:0 / em:0 / etc.) whose act_power field carries the grid power. - MQTT: any power meter publishing a plain numeric value or a JSON object with an act_power / total_act_power field (Shelly EM / 3EM style) can be used by subscribing to a configurable "Grid Power Topic" on the existing OpenDTU MQTT client. Retained messages are ignored so stale retained values never drive the regulation. Grid sources are modelled as a small ZeroExportGridSource interface that tracks measurement freshness, estimates the source update period as an EWMA of the intervals between accepted samples, and enforces a per-source fail-safe timeout. Adding a new source means implementing the interface and adding a switch case. The regulation loop reads the grid power from the active source and distributes the needed correction proportionally to the inverters' rated power, never commanding an inverter below a configurable minimal production (default: 40 W per inverter). Inverters that are temporarily unreachable keep their last commanded limit while the others compensate. Upward corrections are damped for slow sources, using the measured source period plus the estimated inverter response latency, to avoid overshoot; downward corrections remain immediate to reduce export. The tracked state is the set of limits this controller has requested, not the values read back from the inverters (the one-time startup adoption below is the only exception). Safety behavior: - Limits are only ever sent to reachable, command-enabled inverters. - On disable, a RelativNonPersistent 100 % release is sent and retried each regulation tick until every command-enabled inverter has received it. - After a DTU restart, limits left by a previous session are reverted by the inverters' own non-persistent-limit timeout; nothing is commanded until regulation is established. On startup each inverter adopts the limit currently active in the inverter once it becomes known through the regular SystemConfigPara poll, instead of guessing one, so a producing inverter is never yanked to another value. Re-enabling after a release starts at nominal power. - When a grid measurement existed but has expired (measurement outage), a minimum-production fail-safe is commanded once per inverter and retried until it could be sent. It is deliberately not kept alive: if the inverter's own non-persistent-limit timeout reverts it to full power, the regulation loop readjusts as soon as fresh grid values arrive again. - A source that has not delivered a single value yet (module just enabled, source just switched, network just reconnected) is a startup condition, not an outage: no RF traffic is generated and the inverters' limits are left untouched. - Requested limits are capped above the currently measured production (with headroom), so they cannot drift far above what the inverters actually produce. The cap's base never drops below the enforced per-inverter floor sum, so a low-light start can always ramp up again. The default regulation interval is 30 seconds (allowed range: 5-3600 seconds). With the current radio layer, each command occupies the radio for its full RX timeout and the command queue also carries the regular poll requests, so a 30 s interval leaves room for a full poll cycle and for the grid source to measure the effect of a correction. Once tbnobody#3225 ("feat(hoymiles): early RX exit for faster inverter control") is merged, a limit command completes in its actual round-trip time (~100-150 ms instead of the full 2000 ms timeout) and a regulation cycle across 8 HMS inverters takes about 2 seconds instead of ~16, which would allow reducing the regulation interval to the 5-second minimum. The settings page exposes: - Enable/disable switch - Grid power setpoint - Minimum production power per inverter (minimum 40 W) - Regulation interval (5-3600 seconds) - Grid source dropdown (Shelly LNM / MQTT) - Shelly LNM multicast group, port and fail-safe timeout (defaults: 239.255.55.55:5555, 10 s) - MQTT grid power topic and fail-safe timeout (default: 30 s) - Live status with a 5-second refresh: grid power, measured grid update interval, and the currently applied production limit The status API additionally reports per-inverter state (commanded limit, pending startup / release / fail-safe flags, reachability, command enablement). Zero-Export state is published under dtu/zeroexport/status (enabled, setpoint, production_limit, grid_update_period), and the module can be controlled through dtu/zeroexport/cmd (enabled, setpoint). Changes received through MQTT are applied live without persisting the configuration to avoid flash wear. Home Assistant integration (when MQTT auto-discovery is enabled) publishes a switch (enabled), a setpoint number, a production-limit sensor and a grid-update-interval diagnostic sensor; the switch and the setpoint can be changed from Home Assistant.
…d sources Add a Zero-Export module that regulates Hoymiles inverter power limits so that the grid power stays around a configurable setpoint (default: 0 W, i.e. neither export to nor import from the grid), based on the grid power received from a configurable grid source. Two sources are currently available: - Shelly LNM (Local Network Messaging): Shelly meters stream LNM status messages through UDP multicast, avoiding periodic HTTP polling. OpenDTU listens with WiFiUDP and processes incoming datagrams from the scheduler without blocking inverter communication. The wire format is a 12-byte binary header starting with the "SL" magic followed by a JSON payload (em1:0 / em:0 / etc.) whose act_power field carries the grid power. - MQTT: any power meter publishing a plain numeric value or a JSON object with an act_power / total_act_power field (Shelly EM / 3EM style) can be used by subscribing to a configurable "Grid Power Topic" on the existing OpenDTU MQTT client. Retained messages are ignored so stale retained values never drive the regulation. Grid sources are modelled as a small ZeroExportGridSource interface that tracks measurement freshness, estimates the source update period as an EWMA of the intervals between accepted samples, and enforces a per-source fail-safe timeout. Adding a new source means implementing the interface and adding a switch case. The regulation loop reads the grid power from the active source and distributes the needed correction proportionally to the inverters' rated power, never commanding an inverter below a configurable minimal production (default: 40 W per inverter). Inverters that are temporarily unreachable keep their last commanded limit while the others compensate. Upward corrections are damped for slow sources, using the measured source period plus the estimated inverter response latency, to avoid overshoot; downward corrections remain immediate to reduce export. The tracked state is the set of limits this controller has requested, not the values read back from the inverters (the one-time startup adoption below is the only exception). Safety behavior: - Limits are only ever sent to reachable, command-enabled inverters. - On disable, a RelativNonPersistent 100 % release is sent and retried each regulation tick until every command-enabled inverter has received it. - After a DTU restart, limits left by a previous session are reverted by the inverters' own non-persistent-limit timeout; nothing is commanded until regulation is established. On startup each inverter adopts the limit currently active in the inverter once it becomes known through the regular SystemConfigPara poll, instead of guessing one, so a producing inverter is never yanked to another value. Re-enabling after a release starts at nominal power. - When a grid measurement existed but has expired (measurement outage), a minimum-production fail-safe is commanded once per inverter and retried until it could be sent. It is deliberately not kept alive: if the inverter's own non-persistent-limit timeout reverts it to full power, the regulation loop readjusts as soon as fresh grid values arrive again. - A source that has not delivered a single value yet (module just enabled, source just switched, network just reconnected) is a startup condition, not an outage: no RF traffic is generated and the inverters' limits are left untouched. - Requested limits are capped above the currently measured production (with headroom), so they cannot drift far above what the inverters actually produce. The cap's base never drops below the enforced per-inverter floor sum, so a low-light start can always ramp up again. The default regulation interval is 30 seconds (allowed range: 5-3600 seconds). With the current radio layer, each command occupies the radio for its full RX timeout and the command queue also carries the regular poll requests, so a 30 s interval leaves room for a full poll cycle and for the grid source to measure the effect of a correction. Once tbnobody#3225 ("feat(hoymiles): early RX exit for faster inverter control") is merged, a limit command completes in its actual round-trip time (~100-150 ms instead of the full 2000 ms timeout) and a regulation cycle across 8 HMS inverters takes about 2 seconds instead of ~16, which would allow reducing the regulation interval to the 5-second minimum. The settings page exposes: - Enable/disable switch - Grid power setpoint - Minimum production power per inverter (minimum 40 W) - Regulation interval (5-3600 seconds) - Grid source dropdown (Shelly LNM / MQTT) - Shelly LNM multicast group, port and fail-safe timeout (defaults: 239.255.55.55:5555, 10 s) - MQTT grid power topic and fail-safe timeout (default: 30 s) - Live status with a 5-second refresh: grid power, measured grid update interval, and the currently applied production limit The status API additionally reports per-inverter state (commanded limit, pending startup / release / fail-safe flags, reachability, command enablement). Zero-Export state is published under dtu/zeroexport/status (enabled, setpoint, production_limit, grid_update_period), and the module can be controlled through dtu/zeroexport/cmd (enabled, setpoint). Changes received through MQTT are applied live without persisting the configuration to avoid flash wear. Home Assistant integration (when MQTT auto-discovery is enabled) publishes a switch (enabled), a setpoint number, a production-limit sensor and a grid-update-interval diagnostic sensor; the switch and the setpoint can be changed from Home Assistant.
…d sources Add a Zero-Export module that regulates Hoymiles inverter power limits so that the grid power stays around a configurable setpoint (default: 0 W, i.e. neither export to nor import from the grid), based on the grid power received from a configurable grid source. Two sources are currently available: - Shelly LNM (Local Network Messaging): Shelly meters stream LNM status messages through UDP multicast, avoiding periodic HTTP polling. OpenDTU listens with WiFiUDP and processes incoming datagrams from the scheduler without blocking inverter communication. The wire format is a 12-byte binary header starting with the "SL" magic followed by a JSON payload (em1:0 / em:0 / etc.) whose act_power field carries the grid power. - MQTT: any power meter publishing a plain numeric value or a JSON object with an act_power / total_act_power field (Shelly EM / 3EM style) can be used by subscribing to a configurable "Grid Power Topic" on the existing OpenDTU MQTT client. Retained messages are ignored so stale retained values never drive the regulation. Grid sources are modelled as a small ZeroExportGridSource interface that tracks measurement freshness, estimates the source update period as an EWMA of the intervals between accepted samples, and enforces a per-source fail-safe timeout. Adding a new source means implementing the interface and adding a switch case. The regulation loop reads the grid power from the active source and distributes the needed correction proportionally to the inverters' rated power, never commanding an inverter below a configurable minimal production (default: 40 W per inverter). Inverters that are temporarily unreachable keep their last commanded limit while the others compensate. Upward corrections are damped for slow sources, using the measured source period plus the estimated inverter response latency, to avoid overshoot; downward corrections remain immediate to reduce export. The tracked state is the set of limits this controller has requested, not the values read back from the inverters (the one-time startup adoption below is the only exception). Safety behavior: - Limits are only ever sent to reachable, command-enabled inverters. - On disable, a RelativNonPersistent 100 % release is sent and retried each regulation tick until every command-enabled inverter has received it. - After a DTU restart, limits left by a previous session are reverted by the inverters' own non-persistent-limit timeout; nothing is commanded until regulation is established. On startup each inverter adopts the limit currently active in the inverter once it becomes known through the regular SystemConfigPara poll, instead of guessing one, so a producing inverter is never yanked to another value. Re-enabling after a release starts at nominal power. - When a grid measurement existed but has expired (measurement outage), a minimum-production fail-safe is commanded once per inverter and retried until it could be sent. It is deliberately not kept alive: if the inverter's own non-persistent-limit timeout reverts it to full power, the regulation loop readjusts as soon as fresh grid values arrive again. - A source that has not delivered a single value yet (module just enabled, source just switched, network just reconnected) is a startup condition, not an outage: no RF traffic is generated and the inverters' limits are left untouched. - Requested limits are capped above the currently measured production (with headroom), so they cannot drift far above what the inverters actually produce. The cap's base never drops below the enforced per-inverter floor sum, so a low-light start can always ramp up again. The default regulation interval is 30 seconds (allowed range: 5-3600 seconds). With the current radio layer, each command occupies the radio for its full RX timeout and the command queue also carries the regular poll requests, so a 30 s interval leaves room for a full poll cycle and for the grid source to measure the effect of a correction. Once tbnobody#3225 ("feat(hoymiles): early RX exit for faster inverter control") is merged, a limit command completes in its actual round-trip time (~100-150 ms instead of the full 2000 ms timeout) and a regulation cycle across 8 HMS inverters takes about 2 seconds instead of ~16, which would allow reducing the regulation interval to the 5-second minimum. The settings page exposes: - Enable/disable switch - Grid power setpoint - Minimum production power per inverter (minimum 40 W) - Regulation interval (5-3600 seconds) - Grid source dropdown (Shelly LNM / MQTT) - Shelly LNM multicast group, port and fail-safe timeout (defaults: 239.255.55.55:5555, 10 s) - MQTT grid power topic and fail-safe timeout (default: 30 s) - Live status with a 5-second refresh: grid power, measured grid update interval, and the currently applied production limit The status API additionally reports per-inverter state (commanded limit, pending startup / release / fail-safe flags, reachability, command enablement). Zero-Export state is published under dtu/zeroexport/status (enabled, setpoint, production_limit, grid_update_period), and the module can be controlled through dtu/zeroexport/cmd (enabled, setpoint). Changes received through MQTT are applied live without persisting the configuration to avoid flash wear. Home Assistant integration (when MQTT auto-discovery is enabled) publishes a switch (enabled), a setpoint number, a production-limit sensor and a grid-update-interval diagnostic sensor; the switch and the setpoint can be changed from Home Assistant.
…d sources Add a Zero-Export module that regulates Hoymiles inverter power limits so that the grid power stays around a configurable setpoint (default: 0 W, i.e. neither export to nor import from the grid), based on the grid power received from a configurable grid source. Two sources are currently available: - Shelly LNM (Local Network Messaging): Shelly meters stream LNM status messages through UDP multicast, avoiding periodic HTTP polling. OpenDTU listens with WiFiUDP and processes incoming datagrams from the scheduler without blocking inverter communication. The wire format is a 12-byte binary header starting with the "SL" magic followed by a JSON payload (em1:0 / em:0 / etc.) whose act_power field carries the grid power. - MQTT: any power meter publishing a plain numeric value or a JSON object with an act_power / total_act_power field (Shelly EM / 3EM style) can be used by subscribing to a configurable "Grid Power Topic" on the existing OpenDTU MQTT client. Retained messages are ignored so stale retained values never drive the regulation. Grid sources are modelled as a small ZeroExportGridSource interface that tracks measurement freshness, estimates the source update period as an EWMA of the intervals between accepted samples, and enforces a per-source fail-safe timeout. Adding a new source means implementing the interface and adding a switch case. The regulation loop reads the grid power from the active source and distributes the needed correction proportionally to the inverters' rated power, never commanding an inverter below a configurable minimal production (default: 40 W per inverter). Inverters that are temporarily unreachable keep their last commanded limit while the others compensate. Upward corrections are damped for slow sources, using the measured source period plus the estimated inverter response latency, to avoid overshoot; downward corrections remain immediate to reduce export. The tracked state is the set of limits this controller has requested, not the values read back from the inverters (the one-time startup adoption below is the only exception). Safety behavior: - Limits are only ever sent to reachable, command-enabled inverters. - On disable, a RelativNonPersistent 100 % release is sent and retried each regulation tick until every command-enabled inverter has received it. - After a DTU restart, limits left by a previous session are reverted by the inverters' own non-persistent-limit timeout; nothing is commanded until regulation is established. On startup each inverter adopts the limit currently active in the inverter once it becomes known through the regular SystemConfigPara poll, instead of guessing one, so a producing inverter is never yanked to another value. Re-enabling after a release starts at nominal power. - When a grid measurement existed but has expired (measurement outage), a minimum-production fail-safe is commanded once per inverter and retried until it could be sent. It is deliberately not kept alive: if the inverter's own non-persistent-limit timeout reverts it to full power, the regulation loop readjusts as soon as fresh grid values arrive again. - A source that has not delivered a single value yet (module just enabled, source just switched, network just reconnected) is a startup condition, not an outage: no RF traffic is generated and the inverters' limits are left untouched. - Requested limits are capped above the currently measured production (with headroom), so they cannot drift far above what the inverters actually produce. The cap's base never drops below the enforced per-inverter floor sum, so a low-light start can always ramp up again. The default regulation interval is 30 seconds (allowed range: 5-3600 seconds). With the current radio layer, each command occupies the radio for its full RX timeout and the command queue also carries the regular poll requests, so a 30 s interval leaves room for a full poll cycle and for the grid source to measure the effect of a correction. Once tbnobody#3225 ("feat(hoymiles): early RX exit for faster inverter control") is merged, a limit command completes in its actual round-trip time (~100-150 ms instead of the full 2000 ms timeout) and a regulation cycle across 8 HMS inverters takes about 2 seconds instead of ~16, which would allow reducing the regulation interval to the 5-second minimum. The settings page exposes: - Enable/disable switch - Grid power setpoint - Minimum production power per inverter (minimum 40 W) - Regulation interval (5-3600 seconds) - Grid source dropdown (Shelly LNM / MQTT) - Shelly LNM multicast group, port and fail-safe timeout (defaults: 239.255.55.55:5555, 10 s) - MQTT grid power topic and fail-safe timeout (default: 30 s) - Live status with a 5-second refresh: grid power, measured grid update interval, and the currently applied production limit The status API additionally reports per-inverter state (commanded limit, pending startup / release / fail-safe flags, reachability, command enablement). Zero-Export state is published under dtu/zeroexport/status (enabled, setpoint, production_limit, grid_update_period), and the module can be controlled through dtu/zeroexport/cmd (enabled, setpoint). Changes received through MQTT are applied live without persisting the configuration to avoid flash wear. Home Assistant integration (when MQTT auto-discovery is enabled) publishes a switch (enabled), a setpoint number, a production-limit sensor and a grid-update-interval diagnostic sensor; the switch and the setpoint can be changed from Home Assistant.
…d sources Add a Zero-Export module that regulates Hoymiles inverter power limits so that the grid power stays around a configurable setpoint (default: 0 W, i.e. neither export to nor import from the grid), based on the grid power received from a configurable grid source. Two sources are currently available: - Shelly LNM (Local Network Messaging): Shelly meters stream LNM status messages through UDP multicast, avoiding periodic HTTP polling. OpenDTU listens with WiFiUDP and processes incoming datagrams from the scheduler without blocking inverter communication. The wire format is a 12-byte binary header starting with the "SL" magic followed by a JSON payload (em1:0 / em:0 / etc.) whose act_power field carries the grid power. - MQTT: any power meter publishing a plain numeric value or a JSON object with an act_power / total_act_power field (Shelly EM / 3EM style) can be used by subscribing to a configurable "Grid Power Topic" on the existing OpenDTU MQTT client. Retained messages are ignored so stale retained values never drive the regulation. Grid sources are modelled as a small ZeroExportGridSource interface that tracks measurement freshness, estimates the source update period as an EWMA of the intervals between accepted samples, and enforces a per-source fail-safe timeout. Adding a new source means implementing the interface and adding a switch case. The regulation loop reads the grid power from the active source and distributes the needed correction proportionally to the inverters' rated power, never commanding an inverter below a configurable minimal production (default: 40 W per inverter). Inverters that are temporarily unreachable keep their last commanded limit while the others compensate. Upward corrections are damped for slow sources, using the measured source period plus the estimated inverter response latency, to avoid overshoot; downward corrections remain immediate to reduce export. The tracked state is the set of limits this controller has requested, not the values read back from the inverters (the one-time startup adoption below is the only exception). Safety behavior: - Limits are only ever sent to reachable, command-enabled inverters. - On disable, a RelativNonPersistent 100 % release is sent and retried each regulation tick until every command-enabled inverter has received it. - After a DTU restart, limits left by a previous session are reverted by the inverters' own non-persistent-limit timeout; nothing is commanded until regulation is established. On startup each inverter adopts the limit currently active in the inverter once it becomes known through the regular SystemConfigPara poll, instead of guessing one, so a producing inverter is never yanked to another value. Re-enabling after a release starts at nominal power. - When a grid measurement existed but has expired (measurement outage), a minimum-production fail-safe is commanded once per inverter and retried until it could be sent. It is deliberately not kept alive: if the inverter's own non-persistent-limit timeout reverts it to full power, the regulation loop readjusts as soon as fresh grid values arrive again. - A source that has not delivered a single value yet (module just enabled, source just switched, network just reconnected) is a startup condition, not an outage: no RF traffic is generated and the inverters' limits are left untouched. - Requested limits are capped above the currently measured production (with headroom), so they cannot drift far above what the inverters actually produce. The cap's base never drops below the enforced per-inverter floor sum, so a low-light start can always ramp up again. The default regulation interval is 30 seconds (allowed range: 5-3600 seconds). With the current radio layer, each command occupies the radio for its full RX timeout and the command queue also carries the regular poll requests, so a 30 s interval leaves room for a full poll cycle and for the grid source to measure the effect of a correction. Once tbnobody#3225 ("feat(hoymiles): early RX exit for faster inverter control") is merged, a limit command completes in its actual round-trip time (~100-150 ms instead of the full 2000 ms timeout) and a regulation cycle across 8 HMS inverters takes about 2 seconds instead of ~16, which would allow reducing the regulation interval to the 5-second minimum. The settings page exposes: - Enable/disable switch - Grid power setpoint - Minimum production power per inverter (minimum 40 W) - Regulation interval (5-3600 seconds) - Grid source dropdown (Shelly LNM / MQTT) - Shelly LNM multicast group, port and fail-safe timeout (defaults: 239.255.55.55:5555, 10 s) - MQTT grid power topic and fail-safe timeout (default: 30 s) - Live status with a 5-second refresh: grid power, measured grid update interval, and the currently applied production limit The status API additionally reports per-inverter state (commanded limit, pending startup / release / fail-safe flags, reachability, command enablement). Zero-Export state is published under dtu/zeroexport/status (enabled, setpoint, production_limit, grid_update_period), and the module can be controlled through dtu/zeroexport/cmd (enabled, setpoint). Changes received through MQTT are applied live without persisting the configuration to avoid flash wear. Home Assistant integration (when MQTT auto-discovery is enabled) publishes a switch (enabled), a setpoint number, a production-limit sensor and a grid-update-interval diagnostic sensor; the switch and the setpoint can be changed from Home Assistant.
…d sources Add a Zero-Export module that regulates Hoymiles inverter power limits so that the grid power stays around a configurable setpoint (default: 0 W, i.e. neither export to nor import from the grid), based on the grid power received from a configurable grid source. Two sources are currently available: - Shelly LNM (Local Network Messaging): Shelly meters stream LNM status messages through UDP multicast, avoiding periodic HTTP polling. OpenDTU listens with WiFiUDP and processes incoming datagrams from the scheduler without blocking inverter communication. The wire format is a 12-byte binary header starting with the "SL" magic followed by a JSON payload (em1:0 / em:0 / etc.) whose act_power field carries the grid power. - MQTT: any power meter publishing a plain numeric value or a JSON object with an act_power / total_act_power field (Shelly EM / 3EM style) can be used by subscribing to a configurable "Grid Power Topic" on the existing OpenDTU MQTT client. Retained messages are ignored so stale retained values never drive the regulation. Grid sources are modelled as a small ZeroExportGridSource interface that tracks measurement freshness, estimates the source update period as an EWMA of the intervals between accepted samples, and enforces a per-source fail-safe timeout. Adding a new source means implementing the interface and adding a switch case. The regulation loop reads the grid power from the active source and distributes the needed correction proportionally to the inverters' rated power, never commanding an inverter below a configurable minimal production (default: 40 W per inverter). Inverters that are temporarily unreachable keep their last commanded limit while the others compensate. Upward corrections are damped for slow sources, using the measured source period plus the estimated inverter response latency, to avoid overshoot; downward corrections remain immediate to reduce export. The tracked state is the set of limits this controller has requested, not the values read back from the inverters (the one-time startup adoption below is the only exception). Safety behavior: - Limits are only ever sent to reachable, command-enabled inverters. - On disable, a RelativNonPersistent 100 % release is sent and retried each regulation tick until every command-enabled inverter has received it. - After a DTU restart, limits left by a previous session are reverted by the inverters' own non-persistent-limit timeout; nothing is commanded until regulation is established. On startup each inverter adopts the limit currently active in the inverter once it becomes known through the regular SystemConfigPara poll, instead of guessing one, so a producing inverter is never yanked to another value. Re-enabling after a release starts at nominal power. - When a grid measurement existed but has expired (measurement outage), a minimum-production fail-safe is commanded once per inverter and retried until it could be sent. It is deliberately not kept alive: if the inverter's own non-persistent-limit timeout reverts it to full power, the regulation loop readjusts as soon as fresh grid values arrive again. - A source that has not delivered a single value yet (module just enabled, source just switched, network just reconnected) is a startup condition, not an outage: no RF traffic is generated and the inverters' limits are left untouched. - Requested limits are capped above the currently measured production (with headroom), so they cannot drift far above what the inverters actually produce. The cap's base never drops below the enforced per-inverter floor sum, so a low-light start can always ramp up again. The default regulation interval is 30 seconds (allowed range: 5-3600 seconds). With the current radio layer, each command occupies the radio for its full RX timeout and the command queue also carries the regular poll requests, so a 30 s interval leaves room for a full poll cycle and for the grid source to measure the effect of a correction. Once tbnobody#3225 ("feat(hoymiles): early RX exit for faster inverter control") is merged, a limit command completes in its actual round-trip time (~100-150 ms instead of the full 2000 ms timeout) and a regulation cycle across 8 HMS inverters takes about 2 seconds instead of ~16, which would allow reducing the regulation interval to the 5-second minimum. The settings page exposes: - Enable/disable switch - Grid power setpoint - Minimum production power per inverter (minimum 40 W) - Regulation interval (5-3600 seconds) - Grid source dropdown (Shelly LNM / MQTT) - Shelly LNM multicast group, port and fail-safe timeout (defaults: 239.255.55.55:5555, 10 s) - MQTT grid power topic and fail-safe timeout (default: 30 s) - Live status with a 5-second refresh: grid power, measured grid update interval, and the currently applied production limit The status API additionally reports per-inverter state (commanded limit, pending startup / release / fail-safe flags, reachability, command enablement). Zero-Export state is published under dtu/zeroexport/status (enabled, setpoint, production_limit, grid_update_period), and the module can be controlled through dtu/zeroexport/cmd (enabled, setpoint). Changes received through MQTT are applied live without persisting the configuration to avoid flash wear. Home Assistant integration (when MQTT auto-discovery is enabled) publishes a switch (enabled), a setpoint number, a production-limit sensor and a grid-update-interval diagnostic sensor; the switch and the setpoint can be changed from Home Assistant.
…d sources Add a Zero-Export module that regulates Hoymiles inverter power limits so that the grid power stays around a configurable setpoint (default: 0 W, i.e. neither export to nor import from the grid), based on the grid power received from a configurable grid source. Two sources are currently available: - Shelly LNM (Local Network Messaging): Shelly meters stream LNM status messages through UDP multicast, avoiding periodic HTTP polling. OpenDTU listens with WiFiUDP and processes incoming datagrams from the scheduler without blocking inverter communication. The wire format is a 12-byte binary header starting with the "SL" magic followed by a JSON payload (em1:0 / em:0 / etc.) whose act_power field carries the grid power. - MQTT: any power meter publishing a plain numeric value or a JSON object with an act_power / total_act_power field (Shelly EM / 3EM style) can be used by subscribing to a configurable "Grid Power Topic" on the existing OpenDTU MQTT client. Retained messages are ignored so stale retained values never drive the regulation. Grid sources are modelled as a small ZeroExportGridSource interface that tracks measurement freshness, estimates the source update period as an EWMA of the intervals between accepted samples, and enforces a per-source fail-safe timeout. Adding a new source means implementing the interface and adding a switch case. The regulation loop reads the grid power from the active source and distributes the needed correction proportionally to the inverters' rated power, never commanding an inverter below a configurable minimal production (default: 40 W per inverter). Inverters that are temporarily unreachable keep their last commanded limit while the others compensate. Upward corrections are damped for slow sources, using the measured source period plus the estimated inverter response latency, to avoid overshoot; downward corrections remain immediate to reduce export. The tracked state is the set of limits this controller has requested, not the values read back from the inverters (the one-time startup adoption below is the only exception). Safety behavior: - Limits are only ever sent to reachable, command-enabled inverters. - On disable, a RelativNonPersistent 100 % release is sent and retried each regulation tick until every command-enabled inverter has received it. - After a DTU restart, limits left by a previous session are reverted by the inverters' own non-persistent-limit timeout; nothing is commanded until regulation is established. On startup each inverter adopts the limit currently active in the inverter once it becomes known through the regular SystemConfigPara poll, instead of guessing one, so a producing inverter is never yanked to another value. Re-enabling after a release starts at nominal power. - When a grid measurement existed but has expired (measurement outage), a minimum-production fail-safe is commanded once per inverter and retried until it could be sent. It is deliberately not kept alive: if the inverter's own non-persistent-limit timeout reverts it to full power, the regulation loop readjusts as soon as fresh grid values arrive again. - A source that has not delivered a single value yet (module just enabled, source just switched, network just reconnected) is a startup condition, not an outage: no RF traffic is generated and the inverters' limits are left untouched. - Requested limits are capped above the currently measured production (with headroom), so they cannot drift far above what the inverters actually produce. The cap's base never drops below the enforced per-inverter floor sum, so a low-light start can always ramp up again. The default regulation interval is 30 seconds (allowed range: 5-3600 seconds). With the current radio layer, each command occupies the radio for its full RX timeout and the command queue also carries the regular poll requests, so a 30 s interval leaves room for a full poll cycle and for the grid source to measure the effect of a correction. Once tbnobody#3225 ("feat(hoymiles): early RX exit for faster inverter control") is merged, a limit command completes in its actual round-trip time (~100-150 ms instead of the full 2000 ms timeout) and a regulation cycle across 8 HMS inverters takes about 2 seconds instead of ~16, which would allow reducing the regulation interval to the 5-second minimum. The settings page exposes: - Enable/disable switch - Grid power setpoint - Minimum production power per inverter (minimum 40 W) - Regulation interval (5-3600 seconds) - Grid source dropdown (Shelly LNM / MQTT) - Shelly LNM multicast group, port and fail-safe timeout (defaults: 239.255.55.55:5555, 10 s) - MQTT grid power topic and fail-safe timeout (default: 30 s) - Live status with a 5-second refresh: grid power, measured grid update interval, and the currently applied production limit The status API additionally reports per-inverter state (commanded limit, pending startup / release / fail-safe flags, reachability, command enablement). Zero-Export state is published under dtu/zeroexport/status (enabled, setpoint, production_limit, grid_update_period), and the module can be controlled through dtu/zeroexport/cmd (enabled, setpoint). Changes received through MQTT are applied live without persisting the configuration to avoid flash wear. Home Assistant integration (when MQTT auto-discovery is enabled) publishes a switch (enabled), a setpoint number, a production-limit sensor and a grid-update-interval diagnostic sensor; the switch and the setpoint can be changed from Home Assistant.
…d sources Add a Zero-Export module that regulates Hoymiles inverter power limits so that the grid power stays around a configurable setpoint (default: 0 W, i.e. neither export to nor import from the grid), based on the grid power received from a configurable grid source. Two sources are currently available: - Shelly LNM (Local Network Messaging): Shelly meters stream LNM status messages through UDP multicast, avoiding periodic HTTP polling. OpenDTU listens with WiFiUDP and processes incoming datagrams from the scheduler without blocking inverter communication. The wire format is a 12-byte binary header starting with the "SL" magic followed by a JSON payload (em1:0 / em:0 / etc.) whose act_power field carries the grid power. - MQTT: any power meter publishing a plain numeric value or a JSON object with an act_power / total_act_power field (Shelly EM / 3EM style) can be used by subscribing to a configurable "Grid Power Topic" on the existing OpenDTU MQTT client. Retained messages are ignored so stale retained values never drive the regulation. Grid sources are modelled as a small ZeroExportGridSource interface that tracks measurement freshness, estimates the source update period as an EWMA of the intervals between accepted samples, and enforces a per-source fail-safe timeout. Adding a new source means implementing the interface and adding a switch case. The regulation loop reads the grid power from the active source and distributes the needed correction proportionally to the inverters' rated power, never commanding an inverter below a configurable minimal production (default: 40 W per inverter). Inverters that are temporarily unreachable keep their last commanded limit while the others compensate. Upward corrections are damped for slow sources, using the measured source period plus the estimated inverter response latency, to avoid overshoot; downward corrections remain immediate to reduce export. The tracked state is the set of limits this controller has requested, not the values read back from the inverters (the one-time startup adoption below is the only exception). Safety behavior: - Limits are only ever sent to reachable, command-enabled inverters. - On disable, a RelativNonPersistent 100 % release is sent and retried each regulation tick until every command-enabled inverter has received it. - After a DTU restart, limits left by a previous session are reverted by the inverters' own non-persistent-limit timeout; nothing is commanded until regulation is established. On startup each inverter adopts the limit currently active in the inverter once it becomes known through the regular SystemConfigPara poll, instead of guessing one, so a producing inverter is never yanked to another value. Re-enabling after a release starts at nominal power. - When a grid measurement existed but has expired (measurement outage), a minimum-production fail-safe is commanded once per inverter and retried until it could be sent. It is deliberately not kept alive: if the inverter's own non-persistent-limit timeout reverts it to full power, the regulation loop readjusts as soon as fresh grid values arrive again. - A source that has not delivered a single value yet (module just enabled, source just switched, network just reconnected) is a startup condition, not an outage: no RF traffic is generated and the inverters' limits are left untouched. - Requested limits are capped above the currently measured production (with headroom), so they cannot drift far above what the inverters actually produce. The cap's base never drops below the enforced per-inverter floor sum, so a low-light start can always ramp up again. The default regulation interval is 30 seconds (allowed range: 5-3600 seconds). With the current radio layer, each command occupies the radio for its full RX timeout and the command queue also carries the regular poll requests, so a 30 s interval leaves room for a full poll cycle and for the grid source to measure the effect of a correction. Once tbnobody#3225 ("feat(hoymiles): early RX exit for faster inverter control") is merged, a limit command completes in its actual round-trip time (~100-150 ms instead of the full 2000 ms timeout) and a regulation cycle across 8 HMS inverters takes about 2 seconds instead of ~16, which would allow reducing the regulation interval to the 5-second minimum. The settings page exposes: - Enable/disable switch - Grid power setpoint - Minimum production power per inverter (minimum 40 W) - Regulation interval (5-3600 seconds) - Grid source dropdown (Shelly LNM / MQTT) - Shelly LNM multicast group, port and fail-safe timeout (defaults: 239.255.55.55:5555, 10 s) - MQTT grid power topic and fail-safe timeout (default: 30 s) - Live status with a 5-second refresh: grid power, measured grid update interval, and the currently applied production limit The status API additionally reports per-inverter state (commanded limit, pending startup / release / fail-safe flags, reachability, command enablement). Zero-Export state is published under dtu/zeroexport/status (enabled, setpoint, production_limit, grid_update_period), and the module can be controlled through dtu/zeroexport/cmd (enabled, setpoint). Changes received through MQTT are applied live without persisting the configuration to avoid flash wear. Home Assistant integration (when MQTT auto-discovery is enabled) publishes a switch (enabled), a setpoint number, a production-limit sensor and a grid-update-interval diagnostic sensor; the switch and the setpoint can be changed from Home Assistant.
…d sources Add a Zero-Export module that regulates Hoymiles inverter power limits so that the grid power stays around a configurable setpoint (default: 0 W, i.e. neither export to nor import from the grid), based on the grid power received from a configurable grid source. Two sources are currently available: - Shelly LNM (Local Network Messaging): Shelly meters stream LNM status messages through UDP multicast, avoiding periodic HTTP polling. OpenDTU listens with WiFiUDP and processes incoming datagrams from the scheduler without blocking inverter communication. The wire format is a 12-byte binary header starting with the "SL" magic followed by a JSON payload (em1:0 / em:0 / etc.) whose act_power field carries the grid power. - MQTT: any power meter publishing a plain numeric value or a JSON object with an act_power / total_act_power field (Shelly EM / 3EM style) can be used by subscribing to a configurable "Grid Power Topic" on the existing OpenDTU MQTT client. Retained messages are ignored so stale retained values never drive the regulation. Grid sources are modelled as a small ZeroExportGridSource interface that tracks measurement freshness, estimates the source update period as an EWMA of the intervals between accepted samples, and enforces a per-source fail-safe timeout. Adding a new source means implementing the interface and adding a switch case. The regulation loop reads the grid power from the active source and distributes the needed correction proportionally to the inverters' rated power, never commanding an inverter below a configurable minimal production (default: 40 W per inverter). Inverters that are temporarily unreachable keep their last commanded limit while the others compensate. Upward corrections are damped for slow sources, using the measured source period plus the estimated inverter response latency, to avoid overshoot; downward corrections remain immediate to reduce export. The tracked state is the set of limits this controller has requested, not the values read back from the inverters (the one-time startup adoption below is the only exception). Safety behavior: - Limits are only ever sent to reachable, command-enabled inverters. - On disable, a RelativNonPersistent 100 % release is sent and retried each regulation tick until every command-enabled inverter has received it. - After a DTU restart, limits left by a previous session are reverted by the inverters' own non-persistent-limit timeout; nothing is commanded until regulation is established. On startup each inverter adopts the limit currently active in the inverter once it becomes known through the regular SystemConfigPara poll, instead of guessing one, so a producing inverter is never yanked to another value. Re-enabling after a release starts at nominal power. - When a grid measurement existed but has expired (measurement outage), a minimum-production fail-safe is commanded once per inverter and retried until it could be sent. It is deliberately not kept alive: if the inverter's own non-persistent-limit timeout reverts it to full power, the regulation loop readjusts as soon as fresh grid values arrive again. - A source that has not delivered a single value yet (module just enabled, source just switched, network just reconnected) is a startup condition, not an outage: no RF traffic is generated and the inverters' limits are left untouched. - Requested limits are capped above the currently measured production (with headroom), so they cannot drift far above what the inverters actually produce. The cap's base never drops below the enforced per-inverter floor sum, so a low-light start can always ramp up again. The default regulation interval is 30 seconds (allowed range: 5-3600 seconds). With the current radio layer, each command occupies the radio for its full RX timeout and the command queue also carries the regular poll requests, so a 30 s interval leaves room for a full poll cycle and for the grid source to measure the effect of a correction. Once tbnobody#3225 ("feat(hoymiles): early RX exit for faster inverter control") is merged, a limit command completes in its actual round-trip time (~100-150 ms instead of the full 2000 ms timeout) and a regulation cycle across 8 HMS inverters takes about 2 seconds instead of ~16, which would allow reducing the regulation interval to the 5-second minimum. The settings page exposes: - Enable/disable switch - Grid power setpoint - Minimum production power per inverter (minimum 40 W) - Regulation interval (5-3600 seconds) - Grid source dropdown (Shelly LNM / MQTT) - Shelly LNM multicast group, port and fail-safe timeout (defaults: 239.255.55.55:5555, 10 s) - MQTT grid power topic and fail-safe timeout (default: 30 s) - Live status with a 5-second refresh: grid power, measured grid update interval, and the currently applied production limit The status API additionally reports per-inverter state (commanded limit, pending startup / release / fail-safe flags, reachability, command enablement). Zero-Export state is published under dtu/zeroexport/status (enabled, setpoint, production_limit, grid_update_period), and the module can be controlled through dtu/zeroexport/cmd (enabled, setpoint). Changes received through MQTT are applied live without persisting the configuration to avoid flash wear. Home Assistant integration (when MQTT auto-discovery is enabled) publishes a switch (enabled), a setpoint number, a production-limit sensor and a grid-update-interval diagnostic sensor; the switch and the setpoint can be changed from Home Assistant.
…d sources Add a Zero-Export module that regulates Hoymiles inverter power limits so that the grid power stays around a configurable setpoint (default: 0 W, i.e. neither export to nor import from the grid), based on the grid power received from a configurable grid source. Two sources are currently available: - Shelly LNM (Local Network Messaging): Shelly meters stream LNM status messages through UDP multicast, avoiding periodic HTTP polling. OpenDTU listens with WiFiUDP and processes incoming datagrams from the scheduler without blocking inverter communication. The wire format is a 12-byte binary header starting with the "SL" magic followed by a JSON payload (em1:0 / em:0 / etc.) whose act_power field carries the grid power. - MQTT: any power meter publishing a plain numeric value or a JSON object with an act_power / total_act_power field (Shelly EM / 3EM style) can be used by subscribing to a configurable "Grid Power Topic" on the existing OpenDTU MQTT client. Retained messages are ignored so stale retained values never drive the regulation. Grid sources are modelled as a small ZeroExportGridSource interface that tracks measurement freshness, estimates the source update period as an EWMA of the intervals between accepted samples, and enforces a per-source fail-safe timeout. Adding a new source means implementing the interface and adding a switch case. The regulation loop reads the grid power from the active source and distributes the needed correction proportionally to the inverters' rated power, never commanding an inverter below a configurable minimal production (default: 40 W per inverter). Inverters that are temporarily unreachable keep their last commanded limit while the others compensate. Upward corrections are damped for slow sources, using the measured source period plus the estimated inverter response latency, to avoid overshoot; downward corrections remain immediate to reduce export. The tracked state is the set of limits this controller has requested, not the values read back from the inverters (the one-time startup adoption below is the only exception). Safety behavior: - Limits are only ever sent to reachable, command-enabled inverters. - On disable, a RelativNonPersistent 100 % release is sent and retried each regulation tick until every command-enabled inverter has received it. - After a DTU restart, limits left by a previous session are reverted by the inverters' own non-persistent-limit timeout; nothing is commanded until regulation is established. On startup each inverter adopts the limit currently active in the inverter once it becomes known through the regular SystemConfigPara poll, instead of guessing one, so a producing inverter is never yanked to another value. Re-enabling after a release starts at nominal power. - When a grid measurement existed but has expired (measurement outage), a minimum-production fail-safe is commanded once per inverter and retried until it could be sent. It is deliberately not kept alive: if the inverter's own non-persistent-limit timeout reverts it to full power, the regulation loop readjusts as soon as fresh grid values arrive again. - A source that has not delivered a single value yet (module just enabled, source just switched, network just reconnected) is a startup condition, not an outage: no RF traffic is generated and the inverters' limits are left untouched. - Requested limits are capped above the currently measured production (with headroom), so they cannot drift far above what the inverters actually produce. The cap's base never drops below the enforced per-inverter floor sum, so a low-light start can always ramp up again. The default regulation interval is 30 seconds (allowed range: 5-3600 seconds). With the current radio layer, each command occupies the radio for its full RX timeout and the command queue also carries the regular poll requests, so a 30 s interval leaves room for a full poll cycle and for the grid source to measure the effect of a correction. Once tbnobody#3225 ("feat(hoymiles): early RX exit for faster inverter control") is merged, a limit command completes in its actual round-trip time (~100-150 ms instead of the full 2000 ms timeout) and a regulation cycle across 8 HMS inverters takes about 2 seconds instead of ~16, which would allow reducing the regulation interval to the 5-second minimum. The settings page exposes: - Enable/disable switch - Grid power setpoint - Minimum production power per inverter (minimum 40 W) - Regulation interval (5-3600 seconds) - Grid source dropdown (Shelly LNM / MQTT) - Shelly LNM multicast group, port and fail-safe timeout (defaults: 239.255.55.55:5555, 10 s) - MQTT grid power topic and fail-safe timeout (default: 30 s) - Live status with a 5-second refresh: grid power, measured grid update interval, and the currently applied production limit The status API additionally reports per-inverter state (commanded limit, pending startup / release / fail-safe flags, reachability, command enablement). Zero-Export state is published under dtu/zeroexport/status (enabled, setpoint, production_limit, grid_update_period), and the module can be controlled through dtu/zeroexport/cmd (enabled, setpoint). Changes received through MQTT are applied live without persisting the configuration to avoid flash wear. Home Assistant integration (when MQTT auto-discovery is enabled) publishes a switch (enabled), a setpoint number, a production-limit sensor and a grid-update-interval diagnostic sensor; the switch and the setpoint can be changed from Home Assistant.
…d sources Add a Zero-Export module that regulates Hoymiles inverter power limits so that the grid power stays around a configurable setpoint (default: 0 W, i.e. neither export to nor import from the grid), based on the grid power received from a configurable grid source. Two sources are currently available: - Shelly LNM (Local Network Messaging): Shelly meters stream LNM status messages through UDP multicast, avoiding periodic HTTP polling. OpenDTU listens with WiFiUDP and processes incoming datagrams from the scheduler without blocking inverter communication. The wire format is a 12-byte binary header starting with the "SL" magic followed by a JSON payload (em1:0 / em:0 / etc.) whose act_power field carries the grid power. - MQTT: any power meter publishing a plain numeric value or a JSON object with an act_power / total_act_power field (Shelly EM / 3EM style) can be used by subscribing to a configurable "Grid Power Topic" on the existing OpenDTU MQTT client. Retained messages are ignored so stale retained values never drive the regulation. Grid sources are modelled as a small ZeroExportGridSource interface that tracks measurement freshness, estimates the source update period as an EWMA of the intervals between accepted samples, and enforces a per-source fail-safe timeout. Adding a new source means implementing the interface and adding a switch case. The regulation loop reads the grid power from the active source and distributes the needed correction proportionally to the inverters' rated power, never commanding an inverter below a configurable minimal production (default: 40 W per inverter). Inverters that are temporarily unreachable keep their last commanded limit while the others compensate. Upward corrections are damped for slow sources, using the measured source period plus the estimated inverter response latency, to avoid overshoot; downward corrections remain immediate to reduce export. The tracked state is the set of limits this controller has requested, not the values read back from the inverters (the one-time startup adoption below is the only exception). Safety behavior: - Limits are only ever sent to reachable, command-enabled inverters. - On disable, a RelativNonPersistent 100 % release is sent and retried each regulation tick until every command-enabled inverter has received it. - After a DTU restart, limits left by a previous session are reverted by the inverters' own non-persistent-limit timeout; nothing is commanded until regulation is established. On startup each inverter adopts the limit currently active in the inverter once it becomes known through the regular SystemConfigPara poll, instead of guessing one, so a producing inverter is never yanked to another value. Re-enabling after a release starts at nominal power. - When a grid measurement existed but has expired (measurement outage), a minimum-production fail-safe is commanded once per inverter and retried until it could be sent. It is deliberately not kept alive: if the inverter's own non-persistent-limit timeout reverts it to full power, the regulation loop readjusts as soon as fresh grid values arrive again. - A source that has not delivered a single value yet (module just enabled, source just switched, network just reconnected) is a startup condition, not an outage: no RF traffic is generated and the inverters' limits are left untouched. - Requested limits are capped above the currently measured production (with headroom), so they cannot drift far above what the inverters actually produce. The cap's base never drops below the enforced per-inverter floor sum, so a low-light start can always ramp up again. The default regulation interval is 30 seconds (allowed range: 5-3600 seconds). With the current radio layer, each command occupies the radio for its full RX timeout and the command queue also carries the regular poll requests, so a 30 s interval leaves room for a full poll cycle and for the grid source to measure the effect of a correction. Once tbnobody#3225 ("feat(hoymiles): early RX exit for faster inverter control") is merged, a limit command completes in its actual round-trip time (~100-150 ms instead of the full 2000 ms timeout) and a regulation cycle across 8 HMS inverters takes about 2 seconds instead of ~16, which would allow reducing the regulation interval to the 5-second minimum. The settings page exposes: - Enable/disable switch - Grid power setpoint - Minimum production power per inverter (minimum 40 W) - Regulation interval (5-3600 seconds) - Grid source dropdown (Shelly LNM / MQTT) - Shelly LNM multicast group, port and fail-safe timeout (defaults: 239.255.55.55:5555, 10 s) - MQTT grid power topic and fail-safe timeout (default: 30 s) - Live status with a 5-second refresh: grid power, measured grid update interval, and the currently applied production limit The status API additionally reports per-inverter state (commanded limit, pending startup / release / fail-safe flags, reachability, command enablement). Zero-Export state is published under dtu/zeroexport/status (enabled, setpoint, production_limit, grid_update_period), and the module can be controlled through dtu/zeroexport/cmd (enabled, setpoint). Changes received through MQTT are applied live without persisting the configuration to avoid flash wear. Home Assistant integration (when MQTT auto-discovery is enabled) publishes a switch (enabled), a setpoint number, a production-limit sensor and a grid-update-interval diagnostic sensor; the switch and the setpoint can be changed from Home Assistant.
|
I already merged #3166 which also introduced commands which don't end up with 0x80. Maybe we need a exception in this program flow as well. |
…d sources Add a Zero-Export module that regulates Hoymiles inverter power limits so that the grid power stays around a configurable setpoint (default: 0 W, i.e. neither export to nor import from the grid), based on the grid power received from a configurable grid source. Two sources are currently available: - Shelly LNM (Local Network Messaging): Shelly meters stream LNM status messages through UDP multicast, avoiding periodic HTTP polling. OpenDTU listens with WiFiUDP and processes incoming datagrams from the scheduler without blocking inverter communication. The wire format is a 12-byte binary header starting with the "SL" magic followed by a JSON payload (em1:0 / em:0 / etc.) whose act_power field carries the grid power. - MQTT: any power meter publishing a plain numeric value or a JSON object with an act_power / total_act_power field (Shelly EM / 3EM style) can be used by subscribing to a configurable "Grid Power Topic" on the existing OpenDTU MQTT client. Retained messages are ignored so stale retained values never drive the regulation. Grid sources are modelled as a small ZeroExportGridSource interface that tracks measurement freshness, estimates the source update period as an EWMA of the intervals between accepted samples, and enforces a per-source fail-safe timeout. Adding a new source means implementing the interface and adding a switch case. The regulation loop reads the grid power from the active source and distributes the needed correction proportionally to the inverters' rated power, never commanding an inverter below a configurable minimal production (default: 40 W per inverter). Inverters that are temporarily unreachable keep their last commanded limit while the others compensate. Upward corrections are damped for slow sources, using the measured source period plus the estimated inverter response latency, to avoid overshoot; downward corrections remain immediate to reduce export. The tracked state is the set of limits this controller has requested, not the values read back from the inverters (the one-time startup adoption below is the only exception). Safety behavior: - Limits are only ever sent to reachable, command-enabled inverters. - On disable, a RelativNonPersistent 100 % release is sent and retried each regulation tick until every command-enabled inverter has received it. - After a DTU restart, limits left by a previous session are reverted by the inverters' own non-persistent-limit timeout; nothing is commanded until regulation is established. On startup each inverter adopts the limit currently active in the inverter once it becomes known through the regular SystemConfigPara poll, instead of guessing one, so a producing inverter is never yanked to another value. Re-enabling after a release starts at nominal power. - When a grid measurement existed but has expired (measurement outage), a minimum-production fail-safe is commanded once per inverter and retried until it could be sent. It is deliberately not kept alive: if the inverter's own non-persistent-limit timeout reverts it to full power, the regulation loop readjusts as soon as fresh grid values arrive again. - A source that has not delivered a single value yet (module just enabled, source just switched, network just reconnected) is a startup condition, not an outage: no RF traffic is generated and the inverters' limits are left untouched. - Requested limits are capped above the currently measured production (with headroom), so they cannot drift far above what the inverters actually produce. The cap's base never drops below the enforced per-inverter floor sum, so a low-light start can always ramp up again. The default regulation interval is 30 seconds (allowed range: 5-3600 seconds). With the current radio layer, each command occupies the radio for its full RX timeout and the command queue also carries the regular poll requests, so a 30 s interval leaves room for a full poll cycle and for the grid source to measure the effect of a correction. Once tbnobody#3225 ("feat(hoymiles): early RX exit for faster inverter control") is merged, a limit command completes in its actual round-trip time (~100-150 ms instead of the full 2000 ms timeout) and a regulation cycle across 8 HMS inverters takes about 2 seconds instead of ~16, which would allow reducing the regulation interval to the 5-second minimum. The settings page exposes: - Enable/disable switch - Grid power setpoint - Minimum production power per inverter (minimum 40 W) - Regulation interval (5-3600 seconds) - Grid source dropdown (Shelly LNM / MQTT) - Shelly LNM multicast group, port and fail-safe timeout (defaults: 239.255.55.55:5555, 10 s) - MQTT grid power topic and fail-safe timeout (default: 30 s) - Live status with a 5-second refresh: grid power, measured grid update interval, and the currently applied production limit The status API additionally reports per-inverter state (commanded limit, pending startup / release / fail-safe flags, reachability, command enablement). Zero-Export state is published under dtu/zeroexport/status (enabled, setpoint, production_limit, grid_update_period), and the module can be controlled through dtu/zeroexport/cmd (enabled, setpoint). Changes received through MQTT are applied live without persisting the configuration to avoid flash wear. Home Assistant integration (when MQTT auto-discovery is enabled) publishes a switch (enabled), a setpoint number, a production-limit sensor and a grid-update-interval diagnostic sensor; the switch and the setpoint can be changed from Home Assistant.
…d sources Add a Zero-Export module that regulates Hoymiles inverter power limits so that the grid power stays around a configurable setpoint (default: 0 W, i.e. neither export to nor import from the grid), based on the grid power received from a configurable grid source. Two sources are currently available: - Shelly LNM (Local Network Messaging): Shelly meters stream LNM status messages through UDP multicast, avoiding periodic HTTP polling. OpenDTU listens with WiFiUDP and processes incoming datagrams from the scheduler without blocking inverter communication. The wire format is a 12-byte binary header starting with the "SL" magic followed by a JSON payload (em1:0 / em:0 / etc.) whose act_power field carries the grid power. - MQTT: any power meter publishing a plain numeric value or a JSON object with an act_power / total_act_power field (Shelly EM / 3EM style) can be used by subscribing to a configurable "Grid Power Topic" on the existing OpenDTU MQTT client. Retained messages are ignored so stale retained values never drive the regulation. Grid sources are modelled as a small ZeroExportGridSource interface that tracks measurement freshness, estimates the source update period as an EWMA of the intervals between accepted samples, and enforces a per-source fail-safe timeout. Adding a new source means implementing the interface and adding a switch case. The regulation loop reads the grid power from the active source and distributes the needed correction proportionally to the inverters' rated power, never commanding an inverter below a configurable minimal production (default: 40 W per inverter). Inverters that are temporarily unreachable keep their last commanded limit while the others compensate. Upward corrections are damped for slow sources, using the measured source period plus the estimated inverter response latency, to avoid overshoot; downward corrections remain immediate to reduce export. The tracked state is the set of limits this controller has requested, not the values read back from the inverters (the one-time startup adoption below is the only exception). Safety behavior: - Limits are only ever sent to reachable, command-enabled inverters. - On disable, a RelativNonPersistent 100 % release is sent and retried each regulation tick until every command-enabled inverter has received it. - After a DTU restart, limits left by a previous session are reverted by the inverters' own non-persistent-limit timeout; nothing is commanded until regulation is established. On startup each inverter adopts the limit currently active in the inverter once it becomes known through the regular SystemConfigPara poll, instead of guessing one, so a producing inverter is never yanked to another value. Re-enabling after a release starts at nominal power. - When a grid measurement existed but has expired (measurement outage), a minimum-production fail-safe is commanded once per inverter and retried until it could be sent. It is deliberately not kept alive: if the inverter's own non-persistent-limit timeout reverts it to full power, the regulation loop readjusts as soon as fresh grid values arrive again. - A source that has not delivered a single value yet (module just enabled, source just switched, network just reconnected) is a startup condition, not an outage: no RF traffic is generated and the inverters' limits are left untouched. - Requested limits are capped above the currently measured production (with headroom), so they cannot drift far above what the inverters actually produce. The cap's base never drops below the enforced per-inverter floor sum, so a low-light start can always ramp up again. The default regulation interval is 30 seconds (allowed range: 5-3600 seconds). With the current radio layer, each command occupies the radio for its full RX timeout and the command queue also carries the regular poll requests, so a 30 s interval leaves room for a full poll cycle and for the grid source to measure the effect of a correction. Once tbnobody#3225 ("feat(hoymiles): early RX exit for faster inverter control") is merged, a limit command completes in its actual round-trip time (~100-150 ms instead of the full 2000 ms timeout) and a regulation cycle across 8 HMS inverters takes about 2 seconds instead of ~16, which would allow reducing the regulation interval to the 5-second minimum. The settings page exposes: - Enable/disable switch - Grid power setpoint - Minimum production power per inverter (minimum 40 W) - Regulation interval (5-3600 seconds) - Grid source dropdown (Shelly LNM / MQTT) - Shelly LNM multicast group, port and fail-safe timeout (defaults: 239.255.55.55:5555, 10 s) - MQTT grid power topic and fail-safe timeout (default: 30 s) - Live status with a 5-second refresh: grid power, measured grid update interval, and the currently applied production limit The status API additionally reports per-inverter state (commanded limit, pending startup / release / fail-safe flags, reachability, command enablement). Zero-Export state is published under dtu/zeroexport/status (enabled, setpoint, production_limit, grid_update_period), and the module can be controlled through dtu/zeroexport/cmd (enabled, setpoint). Changes received through MQTT are applied live without persisting the configuration to avoid flash wear. Home Assistant integration (when MQTT auto-discovery is enabled) publishes a switch (enabled), a setpoint number, a production-limit sensor and a grid-update-interval diagnostic sensor; the switch and the setpoint can be changed from Home Assistant.
FYI 3 people I know of are testing this change since 3 days so far no issue :-) For the commands which don't end up with 0x80, if you know the end you can add, otherwise the default timeout in place will be used to determine the end. |
…d sources Add a Zero-Export module that regulates Hoymiles inverter power limits so that the grid power stays around a configurable setpoint (default: 0 W, i.e. neither export to nor import from the grid), based on the grid power received from a configurable grid source. Two sources are currently available: - Shelly LNM (Local Network Messaging): Shelly meters stream LNM status messages through UDP multicast, avoiding periodic HTTP polling. OpenDTU listens with WiFiUDP and processes incoming datagrams from the scheduler without blocking inverter communication. The wire format is a 12-byte binary header starting with the "SL" magic followed by a JSON payload (em1:0 / em:0 / etc.) whose act_power field carries the grid power. - MQTT: any power meter publishing a plain numeric value or a JSON object with an act_power / total_act_power field (Shelly EM / 3EM style) can be used by subscribing to a configurable "Grid Power Topic" on the existing OpenDTU MQTT client. Retained messages are ignored so stale retained values never drive the regulation. Grid sources are modelled as a small ZeroExportGridSource interface that tracks measurement freshness, estimates the source update period as an EWMA of the intervals between accepted samples, and enforces a per-source fail-safe timeout. Adding a new source means implementing the interface and adding a switch case. The regulation loop reads the grid power from the active source and distributes the needed correction proportionally to the inverters' rated power, never commanding an inverter below a configurable minimal production (default: 40 W per inverter). Inverters that are temporarily unreachable keep their last commanded limit while the others compensate. Upward corrections are damped for slow sources, using the measured source period plus the estimated inverter response latency, to avoid overshoot; downward corrections remain immediate to reduce export. The tracked state is the set of limits this controller has requested, not the values read back from the inverters (the one-time startup adoption below is the only exception). Safety behavior: - Limits are only ever sent to reachable, command-enabled inverters. - On disable, a RelativNonPersistent 100 % release is sent and retried each regulation tick until every command-enabled inverter has received it. - After a DTU restart, limits left by a previous session are reverted by the inverters' own non-persistent-limit timeout; nothing is commanded until regulation is established. On startup each inverter adopts the limit currently active in the inverter once it becomes known through the regular SystemConfigPara poll, instead of guessing one, so a producing inverter is never yanked to another value. Re-enabling after a release starts at nominal power. - When a grid measurement existed but has expired (measurement outage), a minimum-production fail-safe is commanded once per inverter and retried until it could be sent. It is deliberately not kept alive: if the inverter's own non-persistent-limit timeout reverts it to full power, the regulation loop readjusts as soon as fresh grid values arrive again. - A source that has not delivered a single value yet (module just enabled, source just switched, network just reconnected) is a startup condition, not an outage: no RF traffic is generated and the inverters' limits are left untouched. - Requested limits are capped above the currently measured production (with headroom), so they cannot drift far above what the inverters actually produce. The cap's base never drops below the enforced per-inverter floor sum, so a low-light start can always ramp up again. The default regulation interval is 30 seconds (allowed range: 5-3600 seconds). With the current radio layer, each command occupies the radio for its full RX timeout and the command queue also carries the regular poll requests, so a 30 s interval leaves room for a full poll cycle and for the grid source to measure the effect of a correction. Once tbnobody#3225 ("feat(hoymiles): early RX exit for faster inverter control") is merged, a limit command completes in its actual round-trip time (~100-150 ms instead of the full 2000 ms timeout) and a regulation cycle across 8 HMS inverters takes about 2 seconds instead of ~16, which would allow reducing the regulation interval to the 5-second minimum. The settings page exposes: - Enable/disable switch - Grid power setpoint - Minimum production power per inverter (minimum 40 W) - Regulation interval (5-3600 seconds) - Grid source dropdown (Shelly LNM / MQTT) - Shelly LNM multicast group, port and fail-safe timeout (defaults: 239.255.55.55:5555, 10 s) - MQTT grid power topic and fail-safe timeout (default: 30 s) - Live status with a 5-second refresh: grid power, measured grid update interval, and the currently applied production limit The status API additionally reports per-inverter state (commanded limit, pending startup / release / fail-safe flags, reachability, command enablement). Zero-Export state is published under dtu/zeroexport/status (enabled, setpoint, production_limit, grid_update_period), and the module can be controlled through dtu/zeroexport/cmd (enabled, setpoint). Changes received through MQTT are applied live without persisting the configuration to avoid flash wear. Home Assistant integration (when MQTT auto-discovery is enabled) publishes a switch (enabled), a setpoint number, a production-limit sensor and a grid-update-interval diagnostic sensor; the switch and the setpoint can be changed from Home Assistant.
…d sources Add a Zero-Export module that regulates Hoymiles inverter power limits so that the grid power stays around a configurable setpoint (default: 0 W, i.e. neither export to nor import from the grid), based on the grid power received from a configurable grid source. Two sources are currently available: - Shelly LNM (Local Network Messaging): Shelly meters stream LNM status messages through UDP multicast, avoiding periodic HTTP polling. OpenDTU listens with WiFiUDP and processes incoming datagrams from the scheduler without blocking inverter communication. The wire format is a 12-byte binary header starting with the "SL" magic followed by a JSON payload (em1:0 / em:0 / etc.) whose act_power field carries the grid power. - MQTT: any power meter publishing a plain numeric value or a JSON object with an act_power / total_act_power field (Shelly EM / 3EM style) can be used by subscribing to a configurable "Grid Power Topic" on the existing OpenDTU MQTT client. Retained messages are ignored so stale retained values never drive the regulation. Grid sources are modelled as a small ZeroExportGridSource interface that tracks measurement freshness, estimates the source update period as an EWMA of the intervals between accepted samples, and enforces a per-source fail-safe timeout. Adding a new source means implementing the interface and adding a switch case. The regulation loop reads the grid power from the active source and distributes the needed correction proportionally to the inverters' rated power, never commanding an inverter below a configurable minimal production (default: 40 W per inverter). Inverters that are temporarily unreachable keep their last commanded limit while the others compensate. Upward corrections are damped for slow sources, using the measured source period plus the estimated inverter response latency, to avoid overshoot; downward corrections remain immediate to reduce export. The tracked state is the set of limits this controller has requested, not the values read back from the inverters (the one-time startup adoption below is the only exception). Safety behavior: - Limits are only ever sent to reachable, command-enabled inverters. - On disable, a RelativNonPersistent 100 % release is sent and retried each regulation tick until every command-enabled inverter has received it. - After a DTU restart, limits left by a previous session are reverted by the inverters' own non-persistent-limit timeout; nothing is commanded until regulation is established. On startup each inverter adopts the limit currently active in the inverter once it becomes known through the regular SystemConfigPara poll, instead of guessing one, so a producing inverter is never yanked to another value. Re-enabling after a release starts at nominal power. - When a grid measurement existed but has expired (measurement outage), a minimum-production fail-safe is commanded once per inverter and retried until it could be sent. It is deliberately not kept alive: if the inverter's own non-persistent-limit timeout reverts it to full power, the regulation loop readjusts as soon as fresh grid values arrive again. - A source that has not delivered a single value yet (module just enabled, source just switched, network just reconnected) is a startup condition, not an outage: no RF traffic is generated and the inverters' limits are left untouched. - Requested limits are capped above the currently measured production (with headroom), so they cannot drift far above what the inverters actually produce. The cap's base never drops below the enforced per-inverter floor sum, so a low-light start can always ramp up again. The default regulation interval is 30 seconds (allowed range: 5-3600 seconds). With the current radio layer, each command occupies the radio for its full RX timeout and the command queue also carries the regular poll requests, so a 30 s interval leaves room for a full poll cycle and for the grid source to measure the effect of a correction. Once tbnobody#3225 ("feat(hoymiles): early RX exit for faster inverter control") is merged, a limit command completes in its actual round-trip time (~100-150 ms instead of the full 2000 ms timeout) and a regulation cycle across 8 HMS inverters takes about 2 seconds instead of ~16, which would allow reducing the regulation interval to the 5-second minimum. The settings page exposes: - Enable/disable switch - Grid power setpoint - Minimum production power per inverter (minimum 40 W) - Regulation interval (5-3600 seconds) - Grid source dropdown (Shelly LNM / MQTT) - Shelly LNM multicast group, port and fail-safe timeout (defaults: 239.255.55.55:5555, 10 s) - MQTT grid power topic and fail-safe timeout (default: 30 s) - Live status with a 5-second refresh: grid power, measured grid update interval, and the currently applied production limit The status API additionally reports per-inverter state (commanded limit, pending startup / release / fail-safe flags, reachability, command enablement). Zero-Export state is published under dtu/zeroexport/status (enabled, setpoint, production_limit, grid_update_period), and the module can be controlled through dtu/zeroexport/cmd (enabled, setpoint). Changes received through MQTT are applied live without persisting the configuration to avoid flash wear. Home Assistant integration (when MQTT auto-discovery is enabled) publishes a switch (enabled), a setpoint number, a production-limit sensor and a grid-update-interval diagnostic sensor; the switch and the setpoint can be changed from Home Assistant.
|
Yes, but early exit will not work for responses without '0x80' . Question is if this has any negative side effects when such responses are received. Without thinking deep into it, I would assume that the timeout will still be triggered. (Which is also Ok because the mentioned command is only executed once) |
Yes that is true. But this PR does not modify the existing behaviour. It just allows to not wait until the timeout finishes when we know com is finished. Some inverters do not answer with 0x80 and that's why for them the code will have to wait until the timeout ends like now. There is no change for them. So instead of slowing down everybody, then, at least, for inverters that answer correctly, an early exit is proposed. This is useless to continue to wait when we know the inverter has answered right ? Especially for a Zero-Export feature, taking 2 sec per request to apply a limit is huge and inefficient: 10 inverters make up for 20 seconds to apply a new power limit, when they can all be applied within 2 seconds if we exit early when we can. |
|
Just read the code again and merged it. Will be included in next release. |
|
Hello @mathieucarbou , @tbnobody , Let me explain why. Some commands, such as the "power limit command" have not yet been completed by the time we receive the response from the inverter. It takes about 1s, before the new limit is settled on the AC output of the inverter. Right now we can trust the timing of the "power limit command". Once the command is complete, we know we have the correct AC power. And now, we transfer the time behavior of the control loop more or less to the external system and leave the correct timing to the external programmer. And if we issue commands too quickly, we encounter control problems such as overshoot, undershoot, and oscillation. Don't get me wrong: I am prepared to deal with the new timing characteristics and possess knowledge of control loops. Maybe we must mark this as a "major change" 🤔 |
Keep as-is would work if we could sent all power limit commands concurrently: when the control loop runs, if it has to send 10 commands concurrently and wait 2 sec for a timeout, that's fine. That' 2 sec max. But the reality is that commands are sent in sequence so by the time the last command will be sent, the other ones will be applied. So we only need to account for 2 second in the control loop AFTER the last command was sent. An easy way is to prevent the regulation loop to be too short. For example in my implementation I prevent the user from setting it lower than 5 seconds, which is enough to let room for the power change to be applied.
Also, do not forget that what is driving a control loop is mostly the measurements and their pace. So if you have a control loop shorter than the interval at which the measurements are coming, you can apply a sort of source-adaptive correction based on the intervals. So I think that's totally fine. What is not acceptable is the current behavior: commands are sent in sequence and waiting for a timeout of 2 sec for a command to be applied, when having 10 inverters make up for 20 seconds, so 22 seconds in total to have a power control applied when all can be done in 2 seconds! That was driving me crazy lol! No wonder why I know some people switched to Ahoy who does not wait for this timeout value but early exit instead. |
…d sources Add a Zero-Export module that regulates Hoymiles inverter power limits so that the grid power stays around a configurable setpoint (default: 0 W, i.e. neither export to nor import from the grid), based on the grid power received from a configurable grid source. Two sources are currently available: - Shelly LNM (Local Network Messaging): Shelly meters stream LNM status messages through UDP multicast, avoiding periodic HTTP polling. OpenDTU listens with WiFiUDP and processes incoming datagrams from the scheduler without blocking inverter communication. The wire format is a 12-byte binary header starting with the "SL" magic followed by a JSON payload (em1:0 / em:0 / etc.) whose act_power field carries the grid power. - MQTT: any power meter publishing a plain numeric value or a JSON object with an act_power / total_act_power field (Shelly EM / 3EM style) can be used by subscribing to a configurable "Grid Power Topic" on the existing OpenDTU MQTT client. Retained messages are ignored so stale retained values never drive the regulation. Grid sources are modelled as a small ZeroExportGridSource interface that tracks measurement freshness, estimates the source update period as an EWMA of the intervals between accepted samples, and enforces a per-source fail-safe timeout. Adding a new source means implementing the interface and adding a switch case. The regulation loop reads the grid power from the active source and distributes the needed correction proportionally to the inverters' rated power, never commanding an inverter below a configurable minimal production (default: 40 W per inverter). Inverters that are temporarily unreachable keep their last commanded limit while the others compensate. Upward corrections are damped for slow sources, using the measured source period plus the estimated inverter response latency, to avoid overshoot; downward corrections remain immediate to reduce export. The tracked state is the set of limits this controller has requested, not the values read back from the inverters (the one-time startup adoption below is the only exception). Safety behavior: - Limits are only ever sent to reachable, command-enabled inverters. - On disable, a RelativNonPersistent 100 % release is sent and retried each regulation tick until every command-enabled inverter has received it. - After a DTU restart, limits left by a previous session are reverted by the inverters' own non-persistent-limit timeout; nothing is commanded until regulation is established. On startup each inverter adopts the limit currently active in the inverter once it becomes known through the regular SystemConfigPara poll, instead of guessing one, so a producing inverter is never yanked to another value. Re-enabling after a release starts at nominal power. - When a grid measurement existed but has expired (measurement outage), a minimum-production fail-safe is commanded once per inverter and retried until it could be sent. It is deliberately not kept alive: if the inverter's own non-persistent-limit timeout reverts it to full power, the regulation loop readjusts as soon as fresh grid values arrive again. - A source that has not delivered a single value yet (module just enabled, source just switched, network just reconnected) is a startup condition, not an outage: no RF traffic is generated and the inverters' limits are left untouched. - Requested limits are capped above the currently measured production (with headroom), so they cannot drift far above what the inverters actually produce. The cap's base never drops below the enforced per-inverter floor sum, so a low-light start can always ramp up again. The default regulation interval is 30 seconds (allowed range: 5-3600 seconds). With the current radio layer, each command occupies the radio for its full RX timeout and the command queue also carries the regular poll requests, so a 30 s interval leaves room for a full poll cycle and for the grid source to measure the effect of a correction. Once tbnobody#3225 ("feat(hoymiles): early RX exit for faster inverter control") is merged, a limit command completes in its actual round-trip time (~100-150 ms instead of the full 2000 ms timeout) and a regulation cycle across 8 HMS inverters takes about 2 seconds instead of ~16, which would allow reducing the regulation interval to the 5-second minimum. The settings page exposes: - Enable/disable switch - Grid power setpoint - Minimum production power per inverter (minimum 40 W) - Regulation interval (5-3600 seconds) - Grid source dropdown (Shelly LNM / MQTT) - Shelly LNM multicast group, port and fail-safe timeout (defaults: 239.255.55.55:5555, 10 s) - MQTT grid power topic and fail-safe timeout (default: 30 s) - Live status with a 5-second refresh: grid power, measured grid update interval, and the currently applied production limit The status API additionally reports per-inverter state (commanded limit, pending startup / release / fail-safe flags, reachability, command enablement). Zero-Export state is published under dtu/zeroexport/status (enabled, setpoint, production_limit, grid_update_period), and the module can be controlled through dtu/zeroexport/cmd (enabled, setpoint). Changes received through MQTT are applied live without persisting the configuration to avoid flash wear. Home Assistant integration (when MQTT auto-discovery is enabled) publishes a switch (enabled), a setpoint number, a production-limit sensor and a grid-update-interval diagnostic sensor; the switch and the setpoint can be changed from Home Assistant.
…d sources Add a Zero-Export module that regulates Hoymiles inverter power limits so that the grid power stays around a configurable setpoint (default: 0 W, i.e. neither export to nor import from the grid), based on the grid power received from a configurable grid source. Two sources are currently available: - Shelly LNM (Local Network Messaging): Shelly meters stream LNM status messages through UDP multicast, avoiding periodic HTTP polling. OpenDTU listens with WiFiUDP and processes incoming datagrams from the scheduler without blocking inverter communication. The wire format is a 12-byte binary header starting with the "SL" magic followed by a JSON payload (em1:0 / em:0 / etc.) whose act_power field carries the grid power. - MQTT: any power meter publishing a plain numeric value or a JSON object with an act_power / total_act_power field (Shelly EM / 3EM style) can be used by subscribing to a configurable "Grid Power Topic" on the existing OpenDTU MQTT client. Retained messages are ignored so stale retained values never drive the regulation. Grid sources are modelled as a small ZeroExportGridSource interface that tracks measurement freshness, estimates the source update period as an EWMA of the intervals between accepted samples, and enforces a per-source fail-safe timeout. Adding a new source means implementing the interface and adding a switch case. The regulation loop reads the grid power from the active source and distributes the needed correction proportionally to the inverters' rated power, never commanding an inverter below a configurable minimal production (default: 40 W per inverter). Inverters that are temporarily unreachable keep their last commanded limit while the others compensate. Upward corrections are damped for slow sources, using the measured source period plus the estimated inverter response latency, to avoid overshoot; downward corrections remain immediate to reduce export. The tracked state is the set of limits this controller has requested, not the values read back from the inverters (the one-time startup adoption below is the only exception). Safety behavior: - Limits are only ever sent to reachable, command-enabled inverters. - On disable, a RelativNonPersistent 100 % release is sent and retried each regulation tick until every command-enabled inverter has received it. - After a DTU restart, limits left by a previous session are reverted by the inverters' own non-persistent-limit timeout; nothing is commanded until regulation is established. On startup each inverter adopts the limit currently active in the inverter once it becomes known through the regular SystemConfigPara poll, instead of guessing one, so a producing inverter is never yanked to another value. Re-enabling after a release starts at nominal power. - When a grid measurement existed but has expired (measurement outage), a minimum-production fail-safe is commanded once per inverter and retried until it could be sent. It is deliberately not kept alive: if the inverter's own non-persistent-limit timeout reverts it to full power, the regulation loop readjusts as soon as fresh grid values arrive again. - A source that has not delivered a single value yet (module just enabled, source just switched, network just reconnected) is a startup condition, not an outage: no RF traffic is generated and the inverters' limits are left untouched. - Requested limits are capped above the currently measured production (with headroom), so they cannot drift far above what the inverters actually produce. The cap's base never drops below the enforced per-inverter floor sum, so a low-light start can always ramp up again. The default regulation interval is 30 seconds (allowed range: 5-3600 seconds). With the current radio layer, each command occupies the radio for its full RX timeout and the command queue also carries the regular poll requests, so a 30 s interval leaves room for a full poll cycle and for the grid source to measure the effect of a correction. Once tbnobody#3225 ("feat(hoymiles): early RX exit for faster inverter control") is merged, a limit command completes in its actual round-trip time (~100-150 ms instead of the full 2000 ms timeout) and a regulation cycle across 8 HMS inverters takes about 2 seconds instead of ~16, which would allow reducing the regulation interval to the 5-second minimum. The settings page exposes: - Enable/disable switch - Grid power setpoint - Minimum production power per inverter (minimum 40 W) - Regulation interval (5-3600 seconds) - Grid source dropdown (Shelly LNM / MQTT) - Shelly LNM multicast group, port and fail-safe timeout (defaults: 239.255.55.55:5555, 10 s) - MQTT grid power topic and fail-safe timeout (default: 30 s) - Live status with a 5-second refresh: grid power, measured grid update interval, and the currently applied production limit The status API additionally reports per-inverter state (commanded limit, pending startup / release / fail-safe flags, reachability, command enablement). Zero-Export state is published under dtu/zeroexport/status (enabled, setpoint, production_limit, grid_update_period), and the module can be controlled through dtu/zeroexport/cmd (enabled, setpoint). Changes received through MQTT are applied live without persisting the configuration to avoid flash wear. Home Assistant integration (when MQTT auto-discovery is enabled) publishes a switch (enabled), a setpoint number, a production-limit sensor and a grid-update-interval diagnostic sensor; the switch and the setpoint can be changed from Home Assistant.
…d sources Add a Zero-Export module that regulates Hoymiles inverter power limits so that the grid power stays around a configurable setpoint (default: 0 W, i.e. neither export to nor import from the grid), based on the grid power received from a configurable grid source. Two sources are currently available: - Shelly LNM (Local Network Messaging): Shelly meters stream LNM status messages through UDP multicast, avoiding periodic HTTP polling. OpenDTU listens with WiFiUDP and processes incoming datagrams from the scheduler without blocking inverter communication. The wire format is a 12-byte binary header starting with the "SL" magic followed by a JSON payload (em1:0 / em:0 / etc.) whose act_power field carries the grid power. - MQTT: any power meter publishing a plain numeric value or a JSON object with an act_power / total_act_power field (Shelly EM / 3EM style) can be used by subscribing to a configurable "Grid Power Topic" on the existing OpenDTU MQTT client. Retained messages are ignored so stale retained values never drive the regulation. Grid sources are modelled as a small ZeroExportGridSource interface that tracks measurement freshness, estimates the source update period as an EWMA of the intervals between accepted samples, and enforces a per-source fail-safe timeout. Adding a new source means implementing the interface and adding a switch case. The regulation loop reads the grid power from the active source and distributes the needed correction proportionally to the inverters' rated power, never commanding an inverter below a configurable minimal production (default: 40 W per inverter). Inverters that are temporarily unreachable keep their last commanded limit while the others compensate. Upward corrections are damped for slow sources, using the measured source period plus the estimated inverter response latency, to avoid overshoot; downward corrections remain immediate to reduce export. The tracked state is the set of limits this controller has requested, not the values read back from the inverters (the one-time startup adoption below is the only exception). Safety behavior: - Limits are only ever sent to reachable, command-enabled inverters. - On disable, a RelativNonPersistent 100 % release is sent and retried each regulation tick until every command-enabled inverter has received it. - After a DTU restart, limits left by a previous session are reverted by the inverters' own non-persistent-limit timeout; nothing is commanded until regulation is established. On startup each inverter adopts the limit currently active in the inverter once it becomes known through the regular SystemConfigPara poll, instead of guessing one, so a producing inverter is never yanked to another value. Re-enabling after a release starts at nominal power. - When a grid measurement existed but has expired (measurement outage), a minimum-production fail-safe is commanded once per inverter and retried until it could be sent. It is deliberately not kept alive: if the inverter's own non-persistent-limit timeout reverts it to full power, the regulation loop readjusts as soon as fresh grid values arrive again. - A source that has not delivered a single value yet (module just enabled, source just switched, network just reconnected) is a startup condition, not an outage: no RF traffic is generated and the inverters' limits are left untouched. - Requested limits are capped above the currently measured production (with headroom), so they cannot drift far above what the inverters actually produce. The cap's base never drops below the enforced per-inverter floor sum, so a low-light start can always ramp up again. The default regulation interval is 30 seconds (allowed range: 5-3600 seconds). With the current radio layer, each command occupies the radio for its full RX timeout and the command queue also carries the regular poll requests, so a 30 s interval leaves room for a full poll cycle and for the grid source to measure the effect of a correction. Once tbnobody#3225 ("feat(hoymiles): early RX exit for faster inverter control") is merged, a limit command completes in its actual round-trip time (~100-150 ms instead of the full 2000 ms timeout) and a regulation cycle across 8 HMS inverters takes about 2 seconds instead of ~16, which would allow reducing the regulation interval to the 5-second minimum. The settings page exposes: - Enable/disable switch - Grid power setpoint - Minimum production power per inverter (minimum 40 W) - Regulation interval (5-3600 seconds) - Grid source dropdown (Shelly LNM / MQTT) - Shelly LNM multicast group, port and fail-safe timeout (defaults: 239.255.55.55:5555, 10 s) - MQTT grid power topic and fail-safe timeout (default: 30 s) - Live status with a 5-second refresh: grid power, measured grid update interval, and the currently applied production limit The status API additionally reports per-inverter state (commanded limit, pending startup / release / fail-safe flags, reachability, command enablement). Zero-Export state is published under dtu/zeroexport/status (enabled, setpoint, production_limit, grid_update_period), and the module can be controlled through dtu/zeroexport/cmd (enabled, setpoint). Changes received through MQTT are applied live without persisting the configuration to avoid flash wear. Home Assistant integration (when MQTT auto-discovery is enabled) publishes a switch (enabled), a setpoint number, a production-limit sensor and a grid-update-interval diagnostic sensor; the switch and the setpoint can be changed from Home Assistant.
…d sources Add a Zero-Export module that regulates Hoymiles inverter power limits so that the grid power stays around a configurable setpoint (default: 0 W, i.e. neither export to nor import from the grid), based on the grid power received from a configurable grid source. Two sources are currently available: - Shelly LNM (Local Network Messaging): Shelly meters stream LNM status messages through UDP multicast, avoiding periodic HTTP polling. OpenDTU listens with WiFiUDP and processes incoming datagrams from the scheduler without blocking inverter communication. The wire format is a 12-byte binary header starting with the "SL" magic followed by a JSON payload (em1:0 / em:0 / etc.) whose act_power field carries the grid power. - MQTT: any power meter publishing a plain numeric value or a JSON object with an act_power / total_act_power field (Shelly EM / 3EM style) can be used by subscribing to a configurable "Grid Power Topic" on the existing OpenDTU MQTT client. Retained messages are ignored so stale retained values never drive the regulation. Grid sources are modelled as a small ZeroExportGridSource interface that tracks measurement freshness, estimates the source update period as an EWMA of the intervals between accepted samples, and enforces a per-source fail-safe timeout. Adding a new source means implementing the interface and adding a switch case. The regulation loop reads the grid power from the active source and distributes the needed correction proportionally to the inverters' rated power, never commanding an inverter below a configurable minimal production (default: 40 W per inverter). Inverters that are temporarily unreachable keep their last commanded limit while the others compensate. Upward corrections are damped for slow sources, using the measured source period plus the estimated inverter response latency, to avoid overshoot; downward corrections remain immediate to reduce export. The tracked state is the set of limits this controller has requested, not the values read back from the inverters (the one-time startup adoption below is the only exception). Safety behavior: - Limits are only ever sent to reachable, command-enabled inverters. - On disable, a RelativNonPersistent 100 % release is sent and retried each regulation tick until every command-enabled inverter has received it. - After a DTU restart, limits left by a previous session are reverted by the inverters' own non-persistent-limit timeout; nothing is commanded until regulation is established. On startup each inverter adopts the limit currently active in the inverter once it becomes known through the regular SystemConfigPara poll, instead of guessing one, so a producing inverter is never yanked to another value. Re-enabling after a release starts at nominal power. - When a grid measurement existed but has expired (measurement outage), a minimum-production fail-safe is commanded once per inverter and retried until it could be sent. It is deliberately not kept alive: if the inverter's own non-persistent-limit timeout reverts it to full power, the regulation loop readjusts as soon as fresh grid values arrive again. - A source that has not delivered a single value yet (module just enabled, source just switched, network just reconnected) is a startup condition, not an outage: no RF traffic is generated and the inverters' limits are left untouched. - Requested limits are capped above the currently measured production (with headroom), so they cannot drift far above what the inverters actually produce. The cap's base never drops below the enforced per-inverter floor sum, so a low-light start can always ramp up again. The default regulation interval is 30 seconds (allowed range: 5-3600 seconds). With the current radio layer, each command occupies the radio for its full RX timeout and the command queue also carries the regular poll requests, so a 30 s interval leaves room for a full poll cycle and for the grid source to measure the effect of a correction. Once tbnobody#3225 ("feat(hoymiles): early RX exit for faster inverter control") is merged, a limit command completes in its actual round-trip time (~100-150 ms instead of the full 2000 ms timeout) and a regulation cycle across 8 HMS inverters takes about 2 seconds instead of ~16, which would allow reducing the regulation interval to the 5-second minimum. The settings page exposes: - Enable/disable switch - Grid power setpoint - Minimum production power per inverter (minimum 40 W) - Regulation interval (5-3600 seconds) - Grid source dropdown (Shelly LNM / MQTT) - Shelly LNM multicast group, port and fail-safe timeout (defaults: 239.255.55.55:5555, 10 s) - MQTT grid power topic and fail-safe timeout (default: 30 s) - Live status with a 5-second refresh: grid power, measured grid update interval, and the currently applied production limit The status API additionally reports per-inverter state (commanded limit, pending startup / release / fail-safe flags, reachability, command enablement). Zero-Export state is published under dtu/zeroexport/status (enabled, setpoint, production_limit, grid_update_period), and the module can be controlled through dtu/zeroexport/cmd (enabled, setpoint). Changes received through MQTT are applied live without persisting the configuration to avoid flash wear. Home Assistant integration (when MQTT auto-discovery is enabled) publishes a switch (enabled), a setpoint number, a production-limit sensor and a grid-update-interval diagnostic sensor; the switch and the setpoint can be changed from Home Assistant.
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new discussion or issue for related concerns. |





Problem
A radio transaction is currently only evaluated once its per-command RX
timeout expires, even when the inverter has already answered completely.
This is most noticeable for device-control commands (power limit,
power on/off), which use a 2000ms timeout: an acknowledgement typically
arrives within ~100ms, but the radio stays busy for the remaining ~1900ms
before the next queued command can be sent.
This makes OpenDTU comparatively slow for use cases that repeatedly send
power limit updates (e.g. dynamic/zero-export power control from an external
regulator such as Home Assistant or OpenDTU-on-Battery), since each update
costs a full timeout instead of the actual round-trip time.
Change
A transaction is now finalized as soon as all of its expected fragments have
been received, instead of waiting for the timeout in every case:
_rxFragmentMaxPacketId). Once that flag has been seen and every fragmentup to it is present, completion is mathematically certain.
InverterAbstract::isTransactionComplete(). UnlikeverifyAllFragments(),it does not touch the retransmit counters, so it can be checked on every
loop iteration without affecting statistics or retry logic.
(
isRxBufferEmpty(), implemented per radio) before finalizing, so afragment belonging to the current response can never be misattributed to
the next transaction.
missing responses, so slow inverters, retransmissions and error handling
behave exactly as before.
Single-frame device-control acknowledgements (power limit, power on/off)
qualify for early exit naturally, since their response is a single 0x81
frame. This reduces the effective cost of a power limit command from the
full 2000ms timeout down to the actual round-trip time (typically
~100-150ms).
ChannelChangeCommandis unaffected: it is fire-and-forget by design (noresponse is ever expected), so
isTransactionComplete()never returns truefor it and it keeps finalizing via its existing 10ms timeout.
Both changes make OpenDTU suitable for fast zero-export regulation loops
(e.g. Home Assistant reading a grid meter and publishing limit setpoints via
MQTT): a limit command now completes in its actual round-trip time
(~100-150ms) instead of the full 2000ms timeout, and it is sent before any
pending read requests.
This set of changes makes OpenDTU as fast as Ahoy for power control (limits).
This PR is based on #3226 and includes its commit.
Compatibility
Impact
Power limit command: full 2000ms timeout → actual round-trip (~100-150ms).
Regulation cycle across 8 HMS inverters: ~16s → ~1s.
Testing
Tested at home on my 8 HMS-1000.
As a consequence:
Some logs showing the changes
opendtu-log-2026-09-18_16-53-27.txt