calc on time - #3777
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates runtime (“on_time”) tracking for consumers to use actual elapsed time between updates, aligns surplus control configuration access to the chargemode_config.surplus section, and ensures consumers participate in hierarchy validation.
Changes:
- Track
consumer.set.on_timeusing timestamp deltas and persist a newset/timestamp_wrote_last_on_timefield. - Include consumers when adding/removing missing/obsolete hierarchy entries.
- Switch surplus feed-in limit/yield reads from
chargemode_config.pv_chargingtochargemode_config.surplus.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/helpermodules/setdata.py | Accepts/validates the new consumer set-topic timestamp_wrote_last_on_time and adjusts consumer topic validation list. |
| packages/control/counter_all/hierarchy.py | Ensures consumer components are added/removed during hierarchy validation. |
| packages/control/consumer/consumer.py | Changes on-time accumulation to use real elapsed time and resets the new timestamp on on_time reset. |
| packages/control/consumer/consumer_data.py | Adds timestamp_wrote_last_on_time to the consumer Set dataclass and publishes it via MQTT metadata. |
| packages/control/algorithm/surplus_controlled.py | Reads feed-in limit/yield from chargemode_config.surplus instead of pv_charging. |
Suppressed comments (1)
packages/control/consumer/consumer.py:85
- process_on_time(): When charge_state transitions to False, timestamp_wrote_last_on_time is not reset. On the next True transition, the delta
now - timestamp_wrote_last_on_timewill include the entire off-time, inflating on_time.
elif self.data.get.charge_state is False:
self.data.control_parameter.timestamp_charge_start = None
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
74
to
+78
| def process_on_time(self): | ||
| if self.data.get.charge_state: | ||
| self.data.set.on_time += data.data.general_data.data.control_interval | ||
| now = timecheck.create_timestamp() | ||
| if self.data.set.timestamp_wrote_last_on_time is None: | ||
| self.data.set.timestamp_wrote_last_on_time = now |
Comment on lines
+103
to
+104
| timestamp_wrote_last_on_time: Optional[float] = field( | ||
| default=None, metadata={"topic": "set/timestamp_wrote_last_on_time"}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.