-
-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Refactor button platform to use indevolt-api 1.4.2 #169063
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 | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -7,7 +7,7 @@ | |||||||||||||
| from typing import Any, Final | ||||||||||||||
|
|
||||||||||||||
| from aiohttp import ClientError | ||||||||||||||
| from indevolt_api import IndevoltAPI, TimeOutException | ||||||||||||||
| from indevolt_api import IndevoltAPI, IndevoltRealtimeAction, TimeOutException | ||||||||||||||
|
|
||||||||||||||
| from homeassistant.config_entries import ConfigEntry | ||||||||||||||
| from homeassistant.const import CONF_HOST, CONF_MODEL | ||||||||||||||
|
|
@@ -24,7 +24,6 @@ | |||||||||||||
| ENERGY_MODE_READ_KEY, | ||||||||||||||
| ENERGY_MODE_WRITE_KEY, | ||||||||||||||
| PORTABLE_MODE, | ||||||||||||||
| REALTIME_ACTION_KEY, | ||||||||||||||
| REALTIME_ACTION_MODE, | ||||||||||||||
| SENSOR_KEYS, | ||||||||||||||
| ) | ||||||||||||||
|
|
@@ -146,19 +145,16 @@ async def async_switch_energy_mode( | |||||||||||||
| if refresh: | ||||||||||||||
| await self.async_request_refresh() | ||||||||||||||
|
|
||||||||||||||
| async def async_execute_realtime_action(self, action: list[int]) -> None: | ||||||||||||||
| async def async_realtime_action( | ||||||||||||||
| self, | ||||||||||||||
| action_code: IndevoltRealtimeAction, | ||||||||||||||
| ) -> None: | ||||||||||||||
| """Switch mode, execute action, and refresh for real-time control.""" | ||||||||||||||
|
|
||||||||||||||
| await self.async_switch_energy_mode(REALTIME_ACTION_MODE, refresh=False) | ||||||||||||||
|
|
||||||||||||||
| try: | ||||||||||||||
| success = await self.async_push_data(REALTIME_ACTION_KEY, action) | ||||||||||||||
|
|
||||||||||||||
| except (DeviceTimeoutError, DeviceConnectionError) as err: | ||||||||||||||
| raise HomeAssistantError( | ||||||||||||||
| translation_domain=DOMAIN, | ||||||||||||||
| translation_key="failed_to_execute_realtime_action", | ||||||||||||||
| ) from err | ||||||||||||||
| match action_code: | ||||||||||||||
| case IndevoltRealtimeAction.STOP: | ||||||||||||||
| success = await self.api.stop() | ||||||||||||||
|
||||||||||||||
| success = await self.api.stop() | |
| success = await self.api.stop() | |
| case _: | |
| raise HomeAssistantError( | |
| f"Unsupported real-time action: {action_code}" | |
| ) |
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.
There is currently only one caller of this function which only uses IndevoltRealtimeAction.STOP - there are thus no uncovered edge cases. Other cases will be added in subsequent PRs in which we can be exhaustive.
Uh oh!
There was an error while loading. Please reload this page.