Python homeassistant.util.Throttle() Examples

The following are 6 code examples of homeassistant.util.Throttle(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module homeassistant.util , or try the search function .
Example #1
Source File: sensor.py    From SmartHouse with MIT License 6 votes vote down vote up
def __init__(self, name, username, password, meter_id, generation, sensor_type):
        self.client_name = name
        self.username = username
        self.password = password
        self.meter_id = meter_id
        self.additional_param_enabled = generation or sensor_type.startswith("generation")
        self.sensor_type = sensor_type
        self.unit = SENSOR_TYPES[sensor_type][1]
        configuration = calculate_configuration(username, password, meter_id)
        self.power_zones = configuration[0]
        self.mode = configuration[1]
        self.power_zones_last_update = configuration[2]
        self.power_zones_last_update_tech = datetime.datetime.now() - datetime.timedelta(days=1)
        self.data = None
        self.params = {}
        self._state = None
        self.update = Throttle(SENSOR_TYPES[sensor_type][0])(self._update)
        if not sensor_type == ZONE:
            self.state_param = SENSOR_TYPES[sensor_type][2]
            self.additional_param_name = SENSOR_TYPES[sensor_type][3][0]
            self.additional_param = SENSOR_TYPES[sensor_type][3][1] 
Example #2
Source File: HeWeather.py    From HomeAssistant_Components with Apache License 2.0 5 votes vote down vote up
def __init__(self,api_key,latitude ,longitude,city,interval,isDebug):
        self._api_key = api_key
        self.latitude = latitude
        self.longitude = longitude
        self.city = city
        self.isDebug = isDebug

        self.data = None

        self.update =  Throttle(interval)(self._update) 
Example #3
Source File: sure_petflap.py    From sure_petcare with GNU General Public License v3.0 5 votes vote down vote up
def Throttle( *args, **kwargs ):
        def decorator( f ):
            return f
        return decorator


#REQUIREMENTS = ['sure_petcare'] 
Example #4
Source File: __init__.py    From hass-circadian_lighting with Apache License 2.0 5 votes vote down vote up
def __init__(self, hass, min_colortemp, max_colortemp,
                    sunrise_offset, sunset_offset, sunrise_time, sunset_time,
                    latitude, longitude, elevation,
                    interval, transition):
        self.hass = hass
        self.data = {}
        self.data['min_colortemp'] = min_colortemp
        self.data['max_colortemp'] = max_colortemp
        self.data['sunrise_offset'] = sunrise_offset
        self.data['sunset_offset'] = sunset_offset
        self.data['sunrise_time'] = sunrise_time
        self.data['sunset_time'] = sunset_time
        self.data['latitude'] = latitude
        self.data['longitude'] = longitude
        self.data['elevation'] = elevation
        self.data['interval'] = interval
        self.data['transition'] = transition
        self.data['timezone'] = self.get_timezone()
        self.data['percent'] = self.calc_percent()
        self.data['colortemp'] = self.calc_colortemp()
        self.data['rgb_color'] = self.calc_rgb()
        self.data['xy_color'] = self.calc_xy()
        self.data['hs_color'] = self.calc_hs()

        self.update = Throttle(timedelta(seconds=interval))(self._update)

        if self.data['sunrise_time'] is not None:
            track_time_change(self.hass, self._update, hour=int(self.data['sunrise_time'].strftime("%H")), minute=int(self.data['sunrise_time'].strftime("%M")), second=int(self.data['sunrise_time'].strftime("%S")))
        else:
            track_sunrise(self.hass, self._update, self.data['sunrise_offset'])
        if self.data['sunset_time'] is not None:
            track_time_change(self.hass, self._update, hour=int(self.data['sunset_time'].strftime("%H")), minute=int(self.data['sunset_time'].strftime("%M")), second=int(self.data['sunset_time'].strftime("%S")))
        else:
            track_sunset(self.hass, self._update, self.data['sunset_offset']) 
Example #5
Source File: sensor.py    From SmartHouse with MIT License 5 votes vote down vote up
def __init__(self, stationId):
    self.stationId = stationId
    self.table = {}
    self.update = Throttle(timedelta(minutes=30))(self._update) 
Example #6
Source File: binary_sensor.py    From SmartHouse with MIT License 5 votes vote down vote up
def __init__(self, x, y, radius, api_key, scan_interval):
        self._x = x
        self._y = y
        self._radius = radius
        self._api_key = api_key
        self.szukaj_burzy_output = None
        self.ostrzezenia_pogodowe_output = None
        self.async_update = Throttle(scan_interval)(self._async_update)