本文整理汇总了Python中homeassistant.util.Throttle方法的典型用法代码示例。如果您正苦于以下问题:Python util.Throttle方法的具体用法?Python util.Throttle怎么用?Python util.Throttle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类homeassistant.util
的用法示例。
在下文中一共展示了util.Throttle方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from homeassistant import util [as 别名]
# 或者: from homeassistant.util import Throttle [as 别名]
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]
示例2: __init__
# 需要导入模块: from homeassistant import util [as 别名]
# 或者: from homeassistant.util import Throttle [as 别名]
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)
示例3: Throttle
# 需要导入模块: from homeassistant import util [as 别名]
# 或者: from homeassistant.util import Throttle [as 别名]
def Throttle( *args, **kwargs ):
def decorator( f ):
return f
return decorator
#REQUIREMENTS = ['sure_petcare']
示例4: __init__
# 需要导入模块: from homeassistant import util [as 别名]
# 或者: from homeassistant.util import Throttle [as 别名]
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'])
示例5: __init__
# 需要导入模块: from homeassistant import util [as 别名]
# 或者: from homeassistant.util import Throttle [as 别名]
def __init__(self, stationId):
self.stationId = stationId
self.table = {}
self.update = Throttle(timedelta(minutes=30))(self._update)
示例6: __init__
# 需要导入模块: from homeassistant import util [as 别名]
# 或者: from homeassistant.util import Throttle [as 别名]
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)