當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。