thomasgermain / pymultiMATIC

Python interface with Vaillant multiMATIC
MIT License
56 stars 11 forks source link

basic question: how to set holiday mode? #64

Closed lecocqe closed 3 years ago

lecocqe commented 3 years ago

Hello Thomas,

trying to use pymultimatic, i got the following question: i try to set holiday mode via the following script:

`#!/usr/bin/env python3

import asyncio
import sys

import aiohttp
from asyncio.tasks import sleep, wait

from pymultimatic.systemmanager import SystemManager
from pymultimatic.model import System

from time import sleep

async def main(user, passw):
    async with aiohttp.ClientSession() as session:
        print('Trying to connect with user ' + user)
        manager = SystemManager(user, passw, session)
        system =  await manager.get_system()

        system.set_holiday_mode
# `https://thomasgermain.github.io/pymultiMATIC/build/html/modes.html#holidaymode`

if __name__ == "__main__":

    user = 'xxxx'
    passw = 'xxxxx'

    asyncio.get_event_loop().run_until_complete(main(user, passw))
    `

i can't find my way.

Best regards,

thomasgermain commented 3 years ago

Hello,

see here: https://github.com/thomasgermain/pymultiMATIC/blob/master/pymultimatic/systemmanager.py#L249 you have to provide start_date, end_date and the target temperature

lecocqe commented 3 years ago

ok found error.


#!/usr/bin/env python3

import datetime as dt
import asyncio
import sys

import aiohttp
from asyncio.tasks import sleep, wait

from pymultimatic.systemmanager import SystemManager
from pymultimatic.model import System

from time import sleep

async def main(user, passw):
    async with aiohttp.ClientSession() as session:
        print('Trying to connect with user ' + user)
        manager = SystemManager(user, passw, session)
        system =  await manager.set_holiday_mode(dt.datetime.now(), dt.datetime.now() + dt.timedelta(3),19.9)    

if __name__ == "__main__":

    user = 'x'
    passw = 'x'

    asyncio.run(main(user, passw))

this works but gives the following (maybe basic, but i'm newbee):

Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x00000197F35171F0>
Traceback (most recent call last):
  File "C:\Users\601570859\AppData\Local\Programs\Python\Python38\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Users\601570859\AppData\Local\Programs\Python\Python38\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Users\601570859\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 719, in call_soon
    self._check_closed()
  File "C:\Users\601570859\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 508, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
thomasgermain commented 3 years ago

you can use asyncio.get_event_loop().run_until_complete(main(user, passw)