mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 09:47:13 +00:00
Throttle ebusd sensors instead of the whole component (#40610)
This commit is contained in:
parent
9cd8f66e14
commit
6ddc6a44a2
@ -1,5 +1,4 @@
|
||||
"""Support for Ebusd daemon for communication with eBUS heating systems."""
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
import socket
|
||||
|
||||
@ -14,7 +13,6 @@ from homeassistant.const import (
|
||||
)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.discovery import load_platform
|
||||
from homeassistant.util import Throttle
|
||||
|
||||
from .const import DOMAIN, SENSOR_TYPES
|
||||
|
||||
@ -26,8 +24,6 @@ CONF_CIRCUIT = "circuit"
|
||||
CACHE_TTL = 900
|
||||
SERVICE_EBUSD_WRITE = "ebusd_write"
|
||||
|
||||
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=15)
|
||||
|
||||
|
||||
def verify_ebusd_config(config):
|
||||
"""Verify eBusd config."""
|
||||
@ -59,6 +55,7 @@ CONFIG_SCHEMA = vol.Schema(
|
||||
|
||||
def setup(hass, config):
|
||||
"""Set up the eBusd component."""
|
||||
_LOGGER.debug("Integration setup started")
|
||||
conf = config[DOMAIN]
|
||||
name = conf[CONF_NAME]
|
||||
circuit = conf[CONF_CIRCUIT]
|
||||
@ -66,7 +63,6 @@ def setup(hass, config):
|
||||
server_address = (conf.get(CONF_HOST), conf.get(CONF_PORT))
|
||||
|
||||
try:
|
||||
_LOGGER.debug("Ebusd integration setup started")
|
||||
|
||||
ebusdpy.init(server_address)
|
||||
hass.data[DOMAIN] = EbusdData(server_address, circuit)
|
||||
@ -95,7 +91,6 @@ class EbusdData:
|
||||
self._address = address
|
||||
self.value = {}
|
||||
|
||||
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
||||
def update(self, name, stype):
|
||||
"""Call the Ebusd API to update the data."""
|
||||
try:
|
||||
|
@ -3,6 +3,7 @@ import datetime
|
||||
import logging
|
||||
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.util import Throttle
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
from .const import DOMAIN
|
||||
@ -13,6 +14,7 @@ TIME_FRAME2_BEGIN = "time_frame2_begin"
|
||||
TIME_FRAME2_END = "time_frame2_end"
|
||||
TIME_FRAME3_BEGIN = "time_frame3_begin"
|
||||
TIME_FRAME3_END = "time_frame3_end"
|
||||
MIN_TIME_BETWEEN_UPDATES = datetime.timedelta(seconds=15)
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@ -85,6 +87,7 @@ class EbusdSensor(Entity):
|
||||
"""Return the unit of measurement."""
|
||||
return self._unit_of_measurement
|
||||
|
||||
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
||||
def update(self):
|
||||
"""Fetch new state data for the sensor."""
|
||||
try:
|
||||
|
Loading…
x
Reference in New Issue
Block a user