Skip to content

Instantly share code, notes, and snippets.

@ALERTua
Last active September 30, 2024 14:03
Show Gist options
  • Save ALERTua/b6201c4ecf01e63d57cab822a3d83894 to your computer and use it in GitHub Desktop.
Save ALERTua/b6201c4ecf01e63d57cab822a3d83894 to your computer and use it in GitHub Desktop.
ha pyoverkiz water heater set date time
# install python 3.12
# create a file with any name and this contents. for example script.py
# https://gist.github.com/ALERTua/b6201c4ecf01e63d57cab822a3d83894
# edit this file, fill the USERNAME and PASSWORD with your Cozytouch username and password
# execute the script using python script.py in the folder of the script file.
# the script authenticates in Cozytouch using your credentials, retrieves your devices, takes the first device and sends setdatetime command with the current date and time and prints the result
import asyncio
import datetime
from pyoverkiz.const import SUPPORTED_SERVERS
from pyoverkiz.client import OverkizClient
from pyoverkiz.enums import Server
from pyoverkiz.models import Command
USERNAME = "USERNAME"
PASSWORD = "PASSWORD"
async def main() -> None:
async with OverkizClient(USERNAME, PASSWORD, server=SUPPORTED_SERVERS[Server.ATLANTIC_COZYTOUCH]) as client:
try:
await client.login()
except Exception as exception: # pylint: disable=broad-except
print(exception)
return
# setup = await client.get_setup()
devices = await client.get_devices()
modbus = [_ for _ in devices if 'modbuslink://' in _.device_url][0]
device_url = modbus.device_url
commands = list(modbus.definition.commands)
commands.sort(key=lambda _: _.command_name)
state = await client.get_state(device_url)
state.sort(key=lambda _: _.name)
now = datetime.datetime.now()
# noinspection PyTypeChecker
cmd = Command('setDateTime', [{
'month': now.month,
'hour': now.hour,
'year': now.year,
'weekday': now.weekday(),
'day': now.day,
'minute': now.minute,
'second': now.second
}])
result = await client.execute_command(device_url, cmd)
print(result)
if __name__ == '__main__':
asyncio.run(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment