コード例 #1
0
 async def _test_connection(self, ip, secret):
     self.wiserhub = wiserHub(ip, secret)
     try:
         return await self.hass.async_add_executor_job(
             self.wiserhub.getWiserHubName)
     except:
         raise
コード例 #2
0
 def set_away_mode(self, away, away_temperature):
     from wiserHeatingAPI import wiserHub
     if self.wiserHubInstance is None:
         self.wiserHubInstance = wiserHub.wiserHub(self.ip, self.secret)
     mode = 'AWAY' if away else 'HOME'
     with self.mutex:
         self.wiserHubInstance.setHomeAwayMode(mode, away_temperature)
         self.force_next_scan()
         return True
コード例 #3
0
 def set_room_mode(self, room_id, mode):
     from wiserHeatingAPI import wiserHub
     if self.wiserHubInstance is None:
         self.wiserHubInstance = wiserHub.wiserHub(self.ip, self.secret)
     with self.mutex:
         self.wiserHubInstance.setRoomMode(room_id, mode, self.boost_temp,
                                           self.boost_time)
         self.force_next_scan()
         return True
コード例 #4
0
 def set_room_temperature(self, room_id, target_temperature):
     _LOGGER.info("set {} to {}".format(room_id, target_temperature))
     from wiserHeatingAPI import wiserHub
     if self.wiserHubInstance is None:
         self.wiserHubInstance = wiserHub.wiserHub(self.ip, self.secret)
     with self.mutex:
         self.wiserHubInstance.setRoomTemperature(room_id,
                                                  target_temperature)
         self.force_next_scan()
         return True
コード例 #5
0
 async def set_system_switch(self, switch, mode):
     if self.wiserhub is None:
         self.wiserhub = wiserHub(self.ip, self.secret)
     _LOGGER.debug("Setting {} system switch to {}.".format(switch, mode))
     try:
         self.wiserhub.setSystemSwitch(switch, mode)
         await self.async_update(no_throttle=True)
     except BaseException as e:
         _LOGGER.debug("Error setting {} system switch! {}".format(
             switch, str(e)))
コード例 #6
0
 def __init__(self, hass, config, ip, secret):
     self._hass = hass
     self._config = config
     self.ip = ip
     self.secret = secret
     self.wiserhub = wiserHub(self.ip, self.secret)
     self.minimum_temp = TEMP_MINIMUM
     self.maximum_temp = TEMP_MAXIMUM
     self.boost_temp = self._config[DOMAIN][0][CONF_BOOST_TEMP]
     self.boost_time = self._config[DOMAIN][0][CONF_BOOST_TEMP_TIME]
コード例 #7
0
 async def set_away_mode(self, away, away_temperature):
     mode = "AWAY" if away else "HOME"
     if self.wiserhub is None:
         self.wiserhub = wiserHub(self.ip, self.secret)
     _LOGGER.debug("Setting away mode to {} with temp {}.".format(
         mode, away_temperature))
     try:
         self.wiserhub.setHomeAwayMode(mode, away_temperature)
         await self.async_update(no_throttle=True)
     except BaseException as e:
         _LOGGER.debug("Error setting away mode! {}".format(str(e)))
コード例 #8
0
 def __init__(self, hass, config_entry, ip, secret):
     self._hass = hass
     self._config_entry = config_entry
     self._name = config_entry.data[CONF_NAME]
     self.ip = ip
     self.secret = secret
     self.wiserhub = wiserHub(self.ip, self.secret)
     self.minimum_temp = TEMP_MINIMUM
     self.maximum_temp = TEMP_MAXIMUM
     self.boost_temp = config_entry.data[
         CONF_BOOST_TEMP] or DEFAULT_BOOST_TEMP
     self.boost_time = (config_entry.data[CONF_BOOST_TEMP_TIME]
                        or DEFAULT_BOOST_TEMP_TIME)
コード例 #9
0
    async def set_hotwater_mode(self, hotwater_mode):
        """

        """
        if self.wiserhub is None:
            self.wiserhub = wiserHub(self.ip, self.secret)
        _LOGGER.info("Setting Hotwater to {} ".format(hotwater_mode))
        # Add small delay to allow hub to update status before refreshing
        await asyncio.sleep(0.5)
        await self.async_update(no_throttle=True)

        try:
            self.wiserhub.setHotwaterMode(hotwater_mode)

        except BaseException as e:
            _LOGGER.debug(
                "Error setting Hotwater Mode to  {}, error {}".format(
                    hotwater_mode, str(e)))
コード例 #10
0
    async def set_smart_plug_state(self, plug_id, state):
        """
        Set the state of the smart plug,
        :param plug_id:
        :param state: Can be On or Off
        :return:
        """
        if self.wiserhub is None:
            self.wiserhub = wiserHub(self.ip, self.secret)
        _LOGGER.info("Setting SmartPlug {} to {} ".format(plug_id, state))

        try:
            self.wiserhub.setSmartPlugState(plug_id, state)
            # Add small delay to allow hub to update status before refreshing
            await asyncio.sleep(0.5)
            await self.async_update(no_throttle=True)

        except BaseException as e:
            _LOGGER.debug("Error setting SmartPlug {} to {}, error {}".format(
                plug_id, state, str(e)))
コード例 #11
0
 def update(self):
     _LOGGER.info("Update Requested")
     from wiserHeatingAPI import wiserHub
     if self.wiserHubInstance is None:
         self.wiserHubInstance = wiserHub.wiserHub(self.ip, self.secret)
     with self.mutex:
         if (time.time() - self.last_updated) >= self.scan_interval:
             _LOGGER.debug("**********************************************")
             _LOGGER.info("Scan Interval exceeeded, updating Wiser " +
                          " DataSet from hub")
             _LOGGER.debug("**********************************************")
             try:
                 self.wiserHubInstance.refreshData()
             except timeout as timeoutex:
                 _LOGGER.error("Timed out whilst connecting to {}, with " +
                               " error {}".format(self.ip, str(timeoutex)))
                 hass.components.persistent_notification.create(
                     "Error: {}" +
                     "<br /> You will need to restart Home Assistant " +
                     " after fixing.".format(ex),
                     title=NOTIFICATION_TITLE,
                     notification_id=NOTIFICATION_ID)
                 return False
             except json.decoder.JSONDecodeError as JSONex:
                 _LOGGER.error(
                     "Data not JSON when getting Data from hub, " +
                     "did you enter the right URL? error {}".format(
                         str(JSONex)))
                 hass.components.persistent_notification.create(
                     "Error: {}" +
                     "<br /> You will need to restart Home Assistant " +
                     " after fixing.".format(ex),
                     title=NOTIFICATION_TITLE,
                     notification_id=NOTIFICATION_ID)
                 return False
             self.last_updated = time.time()
             return True
         else:
             _LOGGER.info("Skipping update (data already gotten within " +
                          " scan interval)")
コード例 #12
0
    def _setup(self, force=False):
        try:
            pwd = os.path.dirname(os.path.abspath(__file__))
            fpath = os.path.join(pwd, 'wiserkeys.params')
            LOGGER.info(fpath)
            with open(fpath, 'r') as f:
                data = f.read().split('\n')
        except FileNotFoundError as e:
            LOGGER.debug("{}, {}".format(e.strerror, fpath)    )
        else:
            wiserkey=""
            wiserip=""

            for lines in data:
                line=lines.split('=')
                if line[0]=='wiserkey':
                    wiserkey=line[1]
                if line[0]=='wiserhubip':
                    wiserhubip=line[1]

        if self.settings.get('wiserkey') is not None:
            wiserkey = self.settings.get('wiserkey')
        if self.settings.get('wiserhubip') is not None:
            wiserhubip = self.settings.get('wiserhubip')
        if self.settings.get('wiserhousename') is not None:
            self.my_house = self.settings.get('wiserhousename')
        else:
            self.my_house = housename
        # connect to the wiser hub
        try:
            try:
                self.wh = wiserHub.wiserHub(wiserhubip,wiserkey)
            except:
                LOGGER.debug("Unable to connect to Wiser Hub {}".format(sys.exc_info()[1])    )
                LOGGER.debug (' Wiser Hub IP= {}'.format(wiserhubip))
                LOGGER.debug (' WiserKey= {}'.format(wiserkey))
        except json.decoder.JSONDecodeError as ex:
            LOGGER.debug("JSON Exception")
コード例 #13
0
 def get_hub_data(self):
     from wiserHeatingAPI import wiserHub
     if self.wiserHubInstance is None:
         self.wiserHubInstance = wiserHub.wiserHub(self.ip, self.secret)
     return self.wiserHubInstance
コード例 #14
0
 def connect(self):
     """Connect to Wiser Hub."""
     self.wiserhub = wiserHub(self.host, self.secret)
     return True
コード例 #15
0
wiserip=""

for lines in data:
   line=lines.split('=')
   if line[0]=='wiserkey':
      wiserkey=line[1]
   if line[0]=='wiserhubip':
      wiserip=line[1]

print (' Wiser Hub IP= {} , WiserKey= {}'.format(wiserip,wiserkey))


try:
#
    
    wh = wiserHub.wiserHub(wiserip,wiserkey)
    # wh.refreshdata()
    # print("itrv 8 is in room {}".format(wh.getDeviceRoom(8)['roomName']))
    # Heating State
    print ("Hot water status {} ".format(wh.getHotwaterRelayStatus()))
    print ("Roomstat humidity {}".format(wh.getRoomStatData(1).get("MeasuredHumidity")))

    print("--------------------------------")
    print ("Raw Room Data {} ".format(wh.getRooms()))
    print("--------------------------------")

    print("--------------------------------")
    dev=wh.getDevices()
    print (" Device Data {} ".format(dev))
    print ("--------------------------------")
コード例 #16
0
 def connect(self):
     """Connect to Wiser Hub."""
     self.wiserhub = wiserHub(self.host, self.secret)
     self._hass.async_create_task(self.async_update())
     return True