generated from ludeeus/integration_blueprint
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from planetmarshall/force-hot-water
Add force hot water switch
- Loading branch information
Showing
13 changed files
with
148 additions
and
46 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
13 changes: 6 additions & 7 deletions
13
custom_components/ha_ecodan/pyecodan/examples/list_devices.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,20 @@ | ||
import asyncio | ||
|
||
import pyecodan | ||
from pyecodan.device import OperationMode | ||
from custom_components.ha_ecodan.pyecodan.client import Client | ||
from custom_components.ha_ecodan.pyecodan.device import OperationMode | ||
|
||
|
||
async def main(): | ||
async with pyecodan.Client() as client: | ||
async with Client() as client: | ||
devices = await client.list_devices() | ||
device = devices["Naze View"] | ||
device = await client.get_device(device["id"]) | ||
|
||
await device.set_operation_mode(OperationMode.Room) | ||
await device.force_hot_water(True) | ||
print(device.name) | ||
print(device.id) | ||
print(device.operation_mode) | ||
print(device.forced_hot_water) | ||
|
||
|
||
if __name__ == "__main__": | ||
loop = asyncio.new_event_loop() | ||
loop.run_until_complete(main()) | ||
asyncio.run(main()) |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import pytest | ||
|
||
from custom_components.ha_ecodan.pyecodan.device import Device | ||
|
||
from unittest.mock import Mock, AsyncMock | ||
|
||
|
||
@pytest.mark.parametrize("force_hot_water", [True, False]) | ||
def test_hot_water_mode_from_state(melcloud, force_hot_water): | ||
client = Mock() | ||
device = Device(client, melcloud.device_state_with(ForcedHotWaterMode=force_hot_water)) | ||
|
||
assert device.forced_hot_water is force_hot_water | ||
|
||
|
||
@pytest.mark.asyncio | ||
@pytest.mark.parametrize("force_hot_water", [True, False]) | ||
async def test_hot_water_mode_from_state(melcloud, force_hot_water): | ||
client = Mock() | ||
client.device_request = AsyncMock(return_value=melcloud.response_with(ForcedHotWaterMode=force_hot_water)) | ||
|
||
device = Device(client, melcloud.device_state) | ||
await device.force_hot_water(force_hot_water) | ||
|
||
client.device_request.assert_awaited_with( | ||
melcloud.request_with(EffectiveFlags=65536, ForcedHotWaterMode=force_hot_water)) |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from unittest.mock import AsyncMock | ||
|
||
import pytest | ||
from homeassistant.components.sensor import SensorDeviceClass | ||
|
||
from custom_components.ha_ecodan.sensor import EcodanSensor, ENTITY_DESCRIPTIONS as SENSOR_ENTITY_DESCRIPTIONS | ||
from custom_components.ha_ecodan.switch import EcodanSwitch, ENTITY_DESCRIPTIONS as SWITCH_ENTITY_DESCRIPTIONS | ||
|
||
|
||
def test_hot_water_sensor_properties(coordinator): | ||
|
||
sensor = EcodanSensor(coordinator(), SENSOR_ENTITY_DESCRIPTIONS[2]) | ||
|
||
assert sensor.device_class == SensorDeviceClass.TEMPERATURE | ||
assert sensor.name == "Hot Water Temperature" | ||
|
||
|
||
def test_hot_water_sensor_value_from_coordinator(coordinator): | ||
data = {"TankWaterTemperature": 47} | ||
|
||
sensor = EcodanSensor(coordinator(data), SENSOR_ENTITY_DESCRIPTIONS[2]) | ||
|
||
assert sensor.native_value == 47 | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_force_hot_water_switch_on(coordinator): | ||
data = {"ForcedHotWaterMode": False} | ||
obj = coordinator(data) | ||
obj.device.force_hot_water = AsyncMock() | ||
|
||
switch = EcodanSwitch(obj, SWITCH_ENTITY_DESCRIPTIONS[1]) | ||
await switch.async_turn_on() | ||
|
||
obj.device.force_hot_water.assert_awaited_with(True) | ||
|
||
@pytest.mark.asyncio | ||
async def test_force_hot_water_switch_off(coordinator): | ||
data = {"ForcedHotWaterMode": True} | ||
obj = coordinator(data) | ||
obj.device.force_hot_water = AsyncMock() | ||
|
||
switch = EcodanSwitch(obj, SWITCH_ENTITY_DESCRIPTIONS[1]) | ||
await switch.async_turn_off() | ||
|
||
obj.device.force_hot_water.assert_awaited_with(False) |
This file was deleted.
Oops, something went wrong.