Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion homeassistant/components/blebox/sensor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""BleBox sensor entities."""

from datetime import datetime

import blebox_uniapi.sensor

from homeassistant.components.sensor import (
Expand Down Expand Up @@ -146,7 +148,7 @@ def native_value(self):
return self._feature.native_value

@property
def last_reset(self):
def last_reset(self) -> datetime | None:
"""Return the time when the sensor was last reset, if implemented."""
native_implementation = getattr(self._feature, "last_reset", None)

Expand Down
27 changes: 14 additions & 13 deletions homeassistant/components/ebusd/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Support for Ebusd daemon for communication with eBUS heating systems."""

import logging
from typing import Any

import ebusdpy
import voluptuous as vol
Expand All @@ -17,7 +18,7 @@
from homeassistant.helpers.discovery import load_platform
from homeassistant.helpers.typing import ConfigType

from .const import DOMAIN, SENSOR_TYPES
from .const import DOMAIN, EBUSD_DATA, SENSOR_TYPES

_LOGGER = logging.getLogger(__name__)

Expand All @@ -28,9 +29,9 @@
SERVICE_EBUSD_WRITE = "ebusd_write"


def verify_ebusd_config(config):
def verify_ebusd_config(config: ConfigType) -> ConfigType:
"""Verify eBusd config."""
circuit = config[CONF_CIRCUIT]
circuit: str = config[CONF_CIRCUIT]
for condition in config[CONF_MONITORED_CONDITIONS]:
if condition not in SENSOR_TYPES[circuit]:
raise vol.Invalid(f"Condition '{condition}' not in '{circuit}'.")
Expand Down Expand Up @@ -59,25 +60,25 @@ def verify_ebusd_config(config):
def setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the eBusd component."""
_LOGGER.debug("Integration setup started")
conf = config[DOMAIN]
name = conf[CONF_NAME]
circuit = conf[CONF_CIRCUIT]
monitored_conditions = conf.get(CONF_MONITORED_CONDITIONS)
server_address = (conf.get(CONF_HOST), conf.get(CONF_PORT))
conf: ConfigType = config[DOMAIN]
name: str = conf[CONF_NAME]
circuit: str = conf[CONF_CIRCUIT]
monitored_conditions: list[str] = conf[CONF_MONITORED_CONDITIONS]
server_address: tuple[str, int] = (conf[CONF_HOST], conf[CONF_PORT])

try:
ebusdpy.init(server_address)
except (TimeoutError, OSError):
return False
hass.data[DOMAIN] = EbusdData(server_address, circuit)
hass.data[EBUSD_DATA] = EbusdData(server_address, circuit)
sensor_config = {
CONF_MONITORED_CONDITIONS: monitored_conditions,
"client_name": name,
"sensor_types": SENSOR_TYPES[circuit],
}
load_platform(hass, Platform.SENSOR, DOMAIN, sensor_config, config)

hass.services.register(DOMAIN, SERVICE_EBUSD_WRITE, hass.data[DOMAIN].write)
hass.services.register(DOMAIN, SERVICE_EBUSD_WRITE, hass.data[EBUSD_DATA].write)

_LOGGER.debug("Ebusd integration setup completed")
return True
Expand All @@ -86,13 +87,13 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool:
class EbusdData:
"""Get the latest data from Ebusd."""

def __init__(self, address, circuit):
def __init__(self, address: tuple[str, int], circuit: str) -> None:
"""Initialize the data object."""
self._circuit = circuit
self._address = address
self.value = {}
self.value: dict[str, Any] = {}

def update(self, name, stype):
def update(self, name: str, stype: int) -> None:
"""Call the Ebusd API to update the data."""
try:
_LOGGER.debug("Opening socket to ebusd %s", name)
Expand Down
Loading
Loading