mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Activate mypy for sesame (#54546)
This commit is contained in:
parent
38a210292f
commit
7524acc38c
@ -1,17 +1,11 @@
|
|||||||
"""Support for Sesame, by CANDY HOUSE."""
|
"""Support for Sesame, by CANDY HOUSE."""
|
||||||
from typing import Callable
|
from __future__ import annotations
|
||||||
|
|
||||||
import pysesame2
|
import pysesame2
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.lock import PLATFORM_SCHEMA, LockEntity
|
from homeassistant.components.lock import PLATFORM_SCHEMA, LockEntity
|
||||||
from homeassistant.const import (
|
from homeassistant.const import ATTR_BATTERY_LEVEL, ATTR_DEVICE_ID, CONF_API_KEY
|
||||||
ATTR_BATTERY_LEVEL,
|
|
||||||
ATTR_DEVICE_ID,
|
|
||||||
CONF_API_KEY,
|
|
||||||
STATE_LOCKED,
|
|
||||||
STATE_UNLOCKED,
|
|
||||||
)
|
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
|
|
||||||
@ -20,9 +14,7 @@ ATTR_SERIAL_NO = "serial"
|
|||||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({vol.Required(CONF_API_KEY): cv.string})
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({vol.Required(CONF_API_KEY): cv.string})
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(
|
def setup_platform(hass, config: ConfigType, add_entities, discovery_info=None):
|
||||||
hass, config: ConfigType, add_entities: Callable[[list], None], discovery_info=None
|
|
||||||
):
|
|
||||||
"""Set up the Sesame platform."""
|
"""Set up the Sesame platform."""
|
||||||
api_key = config.get(CONF_API_KEY)
|
api_key = config.get(CONF_API_KEY)
|
||||||
|
|
||||||
@ -35,20 +27,20 @@ def setup_platform(
|
|||||||
class SesameDevice(LockEntity):
|
class SesameDevice(LockEntity):
|
||||||
"""Representation of a Sesame device."""
|
"""Representation of a Sesame device."""
|
||||||
|
|
||||||
def __init__(self, sesame: object) -> None:
|
def __init__(self, sesame: pysesame2.Sesame) -> None:
|
||||||
"""Initialize the Sesame device."""
|
"""Initialize the Sesame device."""
|
||||||
self._sesame = sesame
|
self._sesame: pysesame2.Sesame = sesame
|
||||||
|
|
||||||
# Cached properties from pysesame object.
|
# Cached properties from pysesame object.
|
||||||
self._device_id = None
|
self._device_id: str | None = None
|
||||||
self._serial = None
|
self._serial = None
|
||||||
self._nickname = None
|
self._nickname: str | None = None
|
||||||
self._is_locked = False
|
self._is_locked = False
|
||||||
self._responsive = False
|
self._responsive = False
|
||||||
self._battery = -1
|
self._battery = -1
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self) -> str:
|
def name(self) -> str | None:
|
||||||
"""Return the name of the device."""
|
"""Return the name of the device."""
|
||||||
return self._nickname
|
return self._nickname
|
||||||
|
|
||||||
@ -62,11 +54,6 @@ class SesameDevice(LockEntity):
|
|||||||
"""Return True if the device is currently locked, else False."""
|
"""Return True if the device is currently locked, else False."""
|
||||||
return self._is_locked
|
return self._is_locked
|
||||||
|
|
||||||
@property
|
|
||||||
def state(self) -> str:
|
|
||||||
"""Get the state of the device."""
|
|
||||||
return STATE_LOCKED if self._is_locked else STATE_UNLOCKED
|
|
||||||
|
|
||||||
def lock(self, **kwargs) -> None:
|
def lock(self, **kwargs) -> None:
|
||||||
"""Lock the device."""
|
"""Lock the device."""
|
||||||
self._sesame.lock()
|
self._sesame.lock()
|
||||||
|
3
mypy.ini
3
mypy.ini
@ -1604,9 +1604,6 @@ ignore_errors = true
|
|||||||
[mypy-homeassistant.components.sense.*]
|
[mypy-homeassistant.components.sense.*]
|
||||||
ignore_errors = true
|
ignore_errors = true
|
||||||
|
|
||||||
[mypy-homeassistant.components.sesame.*]
|
|
||||||
ignore_errors = true
|
|
||||||
|
|
||||||
[mypy-homeassistant.components.sharkiq.*]
|
[mypy-homeassistant.components.sharkiq.*]
|
||||||
ignore_errors = true
|
ignore_errors = true
|
||||||
|
|
||||||
|
@ -127,7 +127,6 @@ IGNORED_MODULES: Final[list[str]] = [
|
|||||||
"homeassistant.components.screenlogic.*",
|
"homeassistant.components.screenlogic.*",
|
||||||
"homeassistant.components.search.*",
|
"homeassistant.components.search.*",
|
||||||
"homeassistant.components.sense.*",
|
"homeassistant.components.sense.*",
|
||||||
"homeassistant.components.sesame.*",
|
|
||||||
"homeassistant.components.sharkiq.*",
|
"homeassistant.components.sharkiq.*",
|
||||||
"homeassistant.components.sma.*",
|
"homeassistant.components.sma.*",
|
||||||
"homeassistant.components.smartthings.*",
|
"homeassistant.components.smartthings.*",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user