예제 #1
0
    def change_set_point(self, session, cool, heat):
        """ Set new heat/cool ScheduleHold values.

            By default, these changes will last until the next Period.

            Args:
                cool: The value above which the LCC should cool the zone.  If in
                heating mode, this parameter must be set to minCSP.

                heat: The value below which the LCC should heat the zone.  If in
                cooling only mode, this parameter must be set to maxHSP.

            FIXME: Does not support PerfectTemp today.
        """
        hd_referer = IC3Session.create_url(IComfort3Zone.MYHOMES_PATH)
        session.request_url(self.hd_url, hd_referer)
        current_millis = (int(time.time()) * 1000) + random.randint(0, 999)
        query = [('zoneId', self.zone_id), ('lccId', self.lcc_id),
                 ('coolSetPoint', str(cool)), ('heatSetPoint', str(heat)),
                 ('isPerfectTempOn', 'false'), ('_', str(current_millis))]
        change_url = IC3Session.create_url(IComfort3Zone.CHANGE_SET_POINT,
                                           query)
        resp = session.request_json(change_url, referer_url=self.hd_url)
        resp_json = session.process_as_json(resp)
        return self.__parse_update(resp_json)
예제 #2
0
 def __init__(self, home_id, lcc_id, zone_id):
     # static, pre-configured entries
     self.zone_id = str(zone_id)
     self.home_id = str(home_id)
     self.lcc_id = str(lcc_id)
     details_referer_query = (('zoneId', self.zone_id), ('homeId',
                                                         self.home_id),
                              ('lccId', self.lcc_id), ('refreshZonedetail',
                                                       'False'))
     self.hd_url = IC3Session.create_url(IComfort3Zone.HD_REFERER_PATH,
                                         details_referer_query)
     mode_sched_query = (('zoneId', self.zone_id), ('lccId', self.lcc_id))
     self.ms_url = IC3Session.create_url(IComfort3Zone.MODE_SCHED_PATH,
                                         mode_sched_query)
예제 #3
0
 def __send_update_request(self, session):
     current_millis = (int(time.time()) * 1000) + random.randint(0, 999)
     details_query = (('zoneid', self.zone_id), ('isPolling', 'true'),
                      ('lccid', self.lcc_id), ('_', str(current_millis)))
     up_url = IC3Session.create_url(IComfort3Zone.DETAILS_PATH,
                                    details_query)
     resp = session.request_json(up_url, self.hd_url)
     resp_json = session.process_as_json(resp)
     return resp_json
예제 #4
0
 def set_away_mode(self, session):
     """ Post to set away mode for an LCC/Zone, and returns current state.
     """
     set_away_url = IC3Session.create_url(IComfort3Zone.SET_AWAY_PATH)
     payload = [('lccId', self.lcc_id), ('currentzoneId', self.zone_id)]
     resp = session.post_url_json(set_away_url, payload, self.hd_url)
     resp_json = session.process_as_json(resp)
     if not resp_json:
         return False
     return self.__parse_update(resp_json)
예제 #5
0
 def change_zone_schedule_id(self, session, schedule_id):
     """ Change the current zone Schedule by ID.
     """
     payload = [('lccId', self.lcc_id), ('zoneId', self.zone_id),
                ('scheduleId', schedule_id)]
     change_zs_url = IC3Session.create_url(IComfort3Zone.CHANGE_ZONE_SCHED)
     resp = session.post_url_json(change_zs_url,
                                  post_data=payload,
                                  referer_url=self.ms_url)
     resp.raise_for_status
     return resp.status_code == 200
예제 #6
0
 def change_system_mode_manual(self, session, schedule_id, period_id, mode):
     """ Change to a manually controlled mode rather than a schedule.
     """
     payload = [('zoneId', self.zone_id), ('lccId', self.lcc_id),
                ('scheduleId', schedule_id), ('periodId', period_id),
                ('mode', mode)]
     sysmode_url = IC3Session.create_url(IComfort3Zone.SYSMODE_MANUAL)
     resp = session.post_url_json(sysmode_url,
                                  post_data=payload,
                                  referer_url=self.ms_url)
     resp.raise_for_status
     return resp.status_code == 200
예제 #7
0
#!/usr/bin/python

import secrets
import time
from session import IComfort3Session
from lcc_zone import IComfort3Zone

s = IComfort3Session()
s.login(secrets.icomfort_username, secrets.icomfort_password)
homes = s.fetch_home_zones()
print ("Starting Away Mode test for homes %s." % homes)
for home in homes:
    for (lcc, zone) in homes[home]:
        s.set_context(home, lcc, zone)
        z = IComfort3Zone(home, lcc, zone)
        print ("Home %s, lcc %s, zone %s" % (home, lcc, zone))
        update = z.fetch_update(s)
        while (update == False):
            print("Fetch failed, retrying.")
            s.logout()
            s = IComfort3Session()
            s.login(secrets.icomfort_username, secrets.icomfort_password, True)
            update = z.fetch_update(s)
        print("Before Set Away: %s" % update['isSysteminAwayMode'])
        away = z.set_away_mode(s)
        print("After Set Away: %s" % away['isSysteminAwayMode'])
        while (away['isSysteminAwayMode'] == 'False'):
            away = z.set_away_mode(s)
            print("After Set Away: %s" % away['isSysteminAwayMode'])

for home in homes: