Skip to content

Commit

Permalink
chore: update types
Browse files Browse the repository at this point in the history
  • Loading branch information
pilotak committed Dec 21, 2024
1 parent c1daa17 commit 7b39fc6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
9 changes: 5 additions & 4 deletions custom_components/mcp2221/binary_sensor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""MCP2221 binary sensor"""

from asyncio import Lock
from datetime import datetime, timedelta
from homeassistant.components.binary_sensor import (
BinarySensorDeviceClass,
Expand Down Expand Up @@ -56,7 +57,7 @@ async def async_setup_platform(
}

# get MCP2221 instance
device_instance: MCP2221.MCP2221() | None = hass.data[DOMAIN].get(
device_instance = hass.data[DOMAIN].get(
binary_sensor.get(CONF_DEVICE_ID))

if not isinstance(device_instance["device"], MCP2221.MCP2221):
Expand Down Expand Up @@ -84,15 +85,15 @@ class MCP2221BinarySensor(ManualTriggerEntity, BinarySensorEntity):
def __init__(
self,
config: ConfigType,
device: MCP2221,
device,
pin: int,
inverted: bool,
interval: timedelta,
) -> None:
"""Initialize the binary sensor."""
super().__init__(self.hass, config)
self._device = device["device"]
self._lock = device["lock"]
self._device: MCP2221.MCP2221 = device["device"]
self._lock: Lock = device["lock"]
self._pin = pin
self._inverted = inverted
self._scan_interval = interval
Expand Down
9 changes: 5 additions & 4 deletions custom_components/mcp2221/sensor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""MCP2221 sensor"""

from asyncio import Lock
from datetime import datetime, timedelta
from typing import Any

Expand Down Expand Up @@ -68,7 +69,7 @@ async def async_setup_platform(
trigger_entity_config[key] = sensor.get(key)

# get MCP2221 instance
device_instance: MCP2221.MCP2221() | None = hass.data[DOMAIN].get(
device_instance = hass.data[DOMAIN].get(
sensor.get(CONF_DEVICE_ID))

if not isinstance(device_instance["device"], MCP2221.MCP2221):
Expand Down Expand Up @@ -113,14 +114,14 @@ def __init__(
hass: HomeAssistant,
config: ConfigType,
value_template: Template | None,
device: MCP2221,
device,
pin: int,
scan_interval: timedelta,
) -> None:
"""Initialize the sensor."""
ManualTriggerSensorEntity.__init__(self, hass, config)
self._device = device["device"]
self._lock = device["lock"]
self._device: MCP2221.MCP2221 = device["device"]
self._lock: Lock = device["lock"]
self._pin = pin
self._scan_interval = scan_interval
self._value_template = value_template
Expand Down
9 changes: 5 additions & 4 deletions custom_components/mcp2221/switch.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""MCP2221 switch"""

from asyncio import Lock
from homeassistant.components.switch import SwitchEntity
from homeassistant.const import (
CONF_PIN,
Expand Down Expand Up @@ -43,7 +44,7 @@ async def async_setup_platform(

# get MCP2221 instance

device_instance: MCP2221.MCP2221() | None = hass.data[DOMAIN].get(
device_instance = hass.data[DOMAIN].get(
switch.get(CONF_DEVICE_ID))

if not isinstance(device_instance["device"], MCP2221.MCP2221):
Expand All @@ -67,13 +68,13 @@ class MCP2221Switch(ManualTriggerEntity, SwitchEntity):
def __init__(
self,
config: ConfigType,
device: MCP2221,
device,
pin: int
) -> None:
"""Initialize the switch."""
super().__init__(self.hass, config)
self._device = device["device"]
self._lock = device["lock"]
self._device: MCP2221.MCP2221 = device["device"]
self._lock: Lock = device["lock"]
self._pin = pin

# init GP
Expand Down

0 comments on commit 7b39fc6

Please sign in to comment.