Repository navigation
Reset discharge limit register for GECloud use, entity edit, external event route #2715
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -465,7 +465,6 @@ async def set_state_external(self, entity_id, state, attributes={}): | |||||
| new_state = {"entity_id": entity_id, "state": state, "attributes": attributes} | ||||||
| old_value = self.get_state(entity_id) | ||||||
| old_state = self.state_data.get(entity_id.lower(), None) | ||||||
| found = False | ||||||
|
|
||||||
| # See if the modified entity is in the CONFIG_ITEMS list | ||||||
| for item in self.base.CONFIG_ITEMS: | ||||||
|
|
@@ -495,13 +494,31 @@ async def set_state_external(self, entity_id, state, attributes={}): | |||||
| await self.base.trigger_callback(service_data) | ||||||
| return | ||||||
|
|
||||||
| if not found: | ||||||
| # If its not found then its a sensor and we can set the state directly | ||||||
| self.set_state(entity_id, state, attributes) | ||||||
| # Call back to Predbat handled entities | ||||||
| domain = entity_id.split(".")[0] if "." in entity_id else "" | ||||||
| service_data = {"domain": domain} | ||||||
| if domain in ["switch", "input_boolean"]: | ||||||
| # For toggle switches, check if value is 'on' or 'off' | ||||||
| service_data["service"] = "turn_on" if new_value else "turn_off" | ||||||
| service_data["service_data"] = {"entity_id": entity_id} | ||||||
| elif domain in ["number", "input_number"]: | ||||||
| service_data["service"] = "set_value" | ||||||
| service_data["service_data"] = {"entity_id": entity_id, "value": new_value} | ||||||
| elif domain in ["select", "input_select"]: | ||||||
| service_data["service"] = "select_option" | ||||||
| service_data["service_data"] = {"entity_id": entity_id, "option": new_value} | ||||||
|
Comment on lines
+506
to
+509
|
||||||
| else: | ||||||
| service_data = None | ||||||
| if service_data: | ||||||
| await self.base.trigger_callback(service_data) | ||||||
| return | ||||||
|
|
||||||
| # If its not found then its a sensor and we can set the state directly | ||||||
| self.set_state(entity_id, state, attributes) | ||||||
|
|
||||||
| # Only trigger on value change or you get too many updates | ||||||
| if (old_value is None) or (new_value != old_value): | ||||||
| await self.trigger_watch_list(entity_id, attributes, old_state, new_state) | ||||||
| # Only trigger on value change or you get too many updates | ||||||
| if (old_value is None) or (new_value != old_value): | ||||||
|
||||||
| await self.base.trigger_watch_list(entity_id, attributes, old_state, new_state) | ||||||
|
||||||
| await self.base.trigger_watch_list(entity_id, attributes, old_state, new_state) | |
| await self.trigger_watch_list(entity_id, attributes, old_state, new_state) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable
new_valueis used but not defined in this scope. It should bestateinstead, which contains the new value passed to the function.