Skip to content

Commit

Permalink
refactor(detailed_hello_world): add type annotations to sensor setup
Browse files Browse the repository at this point in the history
  • Loading branch information
HipsterBrown committed Aug 20, 2024
1 parent 51597dd commit 6816f75
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
3 changes: 1 addition & 2 deletions custom_components/detailed_hello_world_push/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
CoverEntityFeature,
CoverEntity,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

Expand All @@ -21,7 +20,7 @@
# This function is called as part of the __init__.async_setup_entry (via the
# hass.config_entries.async_forward_entry_setup call)
async def async_setup_entry(
_hass: HomeAssistant,
hass: HomeAssistant,
config_entry: HubConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
Expand Down
13 changes: 8 additions & 5 deletions custom_components/detailed_hello_world_push/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,28 @@

from homeassistant.components.sensor import (
SensorDeviceClass,
SensorEntity,
SensorStateClass,
)
from homeassistant.const import (
ATTR_VOLTAGE,
PERCENTAGE,
LIGHT_LUX,
ATTR_UNIT_OF_MEASUREMENT,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import HubConfigEntry
from .const import DOMAIN


# See cover.py for more details.
# Note how both entities for each roller sensor (battry and illuminance) are added at
# the same time to the same list. This way only a single async_add_devices call is
# required.
async def async_setup_entry(_hass, config_entry, async_add_entities):
async def async_setup_entry(
hass: HomeAssistant,
config_entry: HubConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Add sensors for passed config_entry in HA."""
hub = config_entry.runtime_data

Expand Down

0 comments on commit 6816f75

Please sign in to comment.