Skip to content

Instantly share code, notes, and snippets.

@tadasdanielius
Last active February 20, 2023 20:07
Show Gist options
  • Save tadasdanielius/e1162a3c36ad1db5aae39dbcae7e7118 to your computer and use it in GitHub Desktop.
Save tadasdanielius/e1162a3c36ad1db5aae39dbcae7e7118 to your computer and use it in GitHub Desktop.
Daikin Altherma EcoMode switch
import asyncio
import aiohttp
from pyaltherma.comm import DaikinWSConnection
from pyaltherma.controllers import AlthermaController, AlthermaClimateControlController, AlthermaUnitController, \
AlthermaWaterTankController
import logging
logging.basicConfig(level=logging.DEBUG)
async def call_operation(controller, operation, value):
destination = f'{controller._dest}/Operation/{operation}'
payload = {
'con': value,
'cnf': 'text/plain:0'
}
return await controller._connection.request(destination, payload=payload)
async def main():
daikin_ip = 'YOUR_DAIKIN_IP_ADDRESS'
async with aiohttp.ClientSession() as session:
conn = DaikinWSConnection(session, daikin_ip)
device = AlthermaController(conn)
await device.discover_units()
print(f'Device info: {await device.device_info()}')
climate_control = device.climate_control
operations = climate_control.operations
print(f'List of operations: {operations}')
print(f'Is EcoMode in the list {"EcoMode" in operations}')
op_values = [0, 1, '0', '1', 'on', 'ecomode', 'eco', 'powerful']
for op_name in ['Power', 'EcoMode', 'ecomode']:
for value in op_values:
print(f'Trying {op_name} with {value} ({value.__class__.__name__})')
response = await call_operation(climate_control, op_name, value)
if 'm2m:rsp' in response:
if 'rsc' in response['m2m:rsp']:
rsc = response['m2m:rsp']['rsc']
if rsc == 2001 or rsc == 2000:
print(f'Valid response received with values {op_name} and {value}')
if rsc == 4004:
print(f'Operation {op_name} not found.')
if rsc == 4005 or rsc == 4102:
print(f'Operation {op_name} value {value} is invalid.')
print(f'[{op_name}({value})]: Response: {response}')
await asyncio.sleep(20)
if __name__ == '__main__':
asyncio.run(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment