Skip to content
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

Add Overkiz AtlanticPassAPCHeatingAndCoolingZone #78659

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
daaea46
Add Overkiz AtlanticPassAPCHeatingAndCoolingZone
nyroDev Sep 17, 2022
2b42f7b
Fix commands instanciations to be simpler
nyroDev Sep 17, 2022
4ea72b8
Update AtlanticPassAPCHeatingAndCoolingZone to show temperature and f…
nyroDev Sep 21, 2022
c483c44
Simplify async_execute_commands in order to receive simpler list
nyroDev Sep 21, 2022
5dc7948
Fix get and set temperature in derogation or auto mode
nyroDev Sep 21, 2022
3aea914
Remove hvac_action from AtlanticPassAPCHeatingAndCoolingZone
nyroDev Sep 22, 2022
d51205f
Remove unused lines
nyroDev Sep 23, 2022
b5c4f9f
Merge branch 'home-assistant:dev' into overkiz/atlantic_pass_apc_heat…
nyroDev Sep 26, 2022
2b6f4a4
Merge branch 'overkiz/atlantic_pass_apc_heating_and_cooling_zone' of …
nyroDev Sep 26, 2022
6cfce13
Merge branch 'home-assistant:dev' into overkiz/atlantic_pass_apc_heat…
nyroDev Sep 28, 2022
dc20991
Merge branch 'overkiz/atlantic_pass_apc_heating_and_cooling_zone' of …
nyroDev Sep 28, 2022
bd2548b
Merge branch 'home-assistant:dev' into overkiz/atlantic_pass_apc_heat…
nyroDev Oct 1, 2022
8a807ea
Merge branch 'overkiz/atlantic_pass_apc_heating_and_cooling_zone' of …
nyroDev Oct 1, 2022
afb7367
Merge branch 'home-assistant:dev' into overkiz/atlantic_pass_apc_heat…
nyroDev Oct 3, 2022
bc6287e
Merge branch 'overkiz/atlantic_pass_apc_heating_and_cooling_zone' of …
nyroDev Oct 3, 2022
4e3c9f8
Update async_execute_commands to work like async_execute_command
nyroDev Oct 3, 2022
bc1a51f
Improve to use preset_home for internal scheduling
nyroDev Oct 3, 2022
2e454b2
Remove async_execute_commands
nyroDev Oct 4, 2022
972a2df
Improvement for AtlanticPassAPCHeatingAndCoolingZone
nyroDev Oct 5, 2022
533b1b8
Merge branch 'home-assistant:dev' into overkiz/atlantic_pass_apc_heat…
nyroDev Oct 17, 2022
82abacb
Merge branch 'home-assistant:dev' into overkiz/atlantic_pass_apc_heat…
nyroDev Oct 28, 2022
c817ba9
Update homeassistant/components/overkiz/climate_entities/__init__.py
nyroDev Nov 3, 2022
e36c56f
Update homeassistant/components/overkiz/climate_entities/atlantic_pas…
nyroDev Nov 3, 2022
ed0c7eb
Update homeassistant/components/overkiz/climate_entities/atlantic_pas…
nyroDev Nov 3, 2022
4c1f098
Update homeassistant/components/overkiz/const.py
nyroDev Nov 3, 2022
0d92ab0
Merge branch 'home-assistant:dev' into overkiz/atlantic_pass_apc_heat…
nyroDev Nov 3, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update async_execute_commands to work like async_execute_command
Implement cancel for multiple commands
  • Loading branch information
nyroDev committed Oct 3, 2022
commit 4e3c9f8e4483e721db144fcc7f2ff03e657bccbb
2 changes: 1 addition & 1 deletion homeassistant/components/overkiz/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __init__(
self.is_stateless = all(
device.protocol in (Protocol.RTS, Protocol.INTERNAL) for device in devices
)
self.executions: dict[str, dict[str, str]] = {}
self.executions: dict[str, Any] = {}
self.areas = self._places_to_area(places) if places else None
self.config_entry_id = config_entry_id

Expand Down
75 changes: 49 additions & 26 deletions homeassistant/components/overkiz/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,44 +73,66 @@ def select_attribute(self, *attributes: str) -> OverkizStateType:
async def async_execute_command(self, command_name: str, *args: Any) -> None:
"""Execute device command in async context."""
parameters = [arg for arg in args if arg is not None]
# Set the execution duration to 0 seconds for RTS devices on supported commands
# Default execution duration is 30 seconds and will block consecutive commands
if (
self.device.protocol == Protocol.RTS
and command_name not in COMMANDS_WITHOUT_DELAY
):
parameters.append(0)

exec_id = await self.coordinator.client.execute_command(
self.device.device_url,
Command(command_name, parameters),
"Home Assistant",
)

# ExecutionRegisteredEvent doesn't contain the device_url, thus we need to register it here
self.coordinator.executions[exec_id] = {
"device_url": self.device.device_url,
"command_name": command_name,
}

await self.coordinator.async_refresh()

commands: list[list | str] = [[command_name, parameters]]
await self.async_execute_commands(commands)

# commands except an array of commands
# each command could be :
# - a simple string to execute a command without parameter
# - a list with command name as first index and parameters list as second index
# Example of usage:
# commands: list[list | str] = [
# [
# OverkizCommand.SET_MODE_TEMPERATURE,
# [OverkizCommandParam.MANUAL_MODE, temperature],
# ],
# [
# OverkizCommand.SET_DEROGATION_ON_OFF_STATE,
# [OverkizCommandParam.OFF],
# ],
# OverkizCommand.REFRESH_PASS_APC_HEATING_MODE,
# OverkizCommand.REFRESH_PASS_APC_HEATING_PROFILE,
# ]
# await self.executor.async_execute_commands(commands)
async def async_execute_commands(self, commands: list[list | str]) -> None:
"""Execute device commands in async context."""

command_names = []
commands_objects = []
for cmd in commands:
parameters = []
if isinstance(cmd, list):
commands_objects.append(Command(cmd[0], cmd[1]))
command_name = cmd[0]
parameters = cmd[1]
else:
commands_objects.append(Command(cmd))
command_name = cmd

# Set the execution duration to 0 seconds for RTS devices on supported commands
# Default execution duration is 30 seconds and will block consecutive commands
if (
self.device.protocol == Protocol.RTS
and command_name not in COMMANDS_WITHOUT_DELAY
):
parameters.append(0)

command_names.append(command_name)
if len(parameters) > 0:
commands_objects.append(Command(command_name, parameters))
else:
commands_objects.append(Command(command_name))

await self.coordinator.client.execute_commands(
exec_id = await self.coordinator.client.execute_commands(
self.device.device_url,
commands_objects,
"Home Assistant",
)

# ExecutionRegisteredEvent doesn't contain the device_url, thus we need to register it here
self.coordinator.executions[exec_id] = {
"device_url": self.device.device_url,
"commands": command_names,
}

await self.coordinator.async_refresh()

async def async_cancel_command(
Expand All @@ -125,8 +147,9 @@ async def async_cancel_command(
exec_id
# Reverse dictionary to cancel the last added execution
for exec_id, execution in reversed(self.coordinator.executions.items())
for command in execution.get("commands")
if execution.get("device_url") == self.device.device_url
and execution.get("command_name") in commands_to_cancel
and command in commands_to_cancel
),
None,
)
Expand Down