当前位置: 首页>>代码示例>>Python>>正文


Python util.Throttle方法代码示例

本文整理汇总了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] 
开发者ID:macbury,项目名称:SmartHouse,代码行数:23,代码来源:sensor.py

示例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) 
开发者ID:charleyzhu,项目名称:HomeAssistant_Components,代码行数:12,代码来源:HeWeather.py

示例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'] 
开发者ID:rcastberg,项目名称:sure_petcare,代码行数:9,代码来源:sure_petflap.py

示例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']) 
开发者ID:claytonjn,项目名称:hass-circadian_lighting,代码行数:36,代码来源:__init__.py

示例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) 
开发者ID:macbury,项目名称:SmartHouse,代码行数:6,代码来源:sensor.py

示例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) 
开发者ID:macbury,项目名称:SmartHouse,代码行数:10,代码来源:binary_sensor.py


注:本文中的homeassistant.util.Throttle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。