mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Simplify imports in mysensors (#125746)
This commit is contained in:
parent
c33ba541b0
commit
09dd647741
@ -17,8 +17,9 @@ from homeassistant.core import HomeAssistant, callback
|
|||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from .. import mysensors
|
from . import setup_mysensors_platform
|
||||||
from .const import MYSENSORS_DISCOVERY, DiscoveryInfo
|
from .const import MYSENSORS_DISCOVERY, DiscoveryInfo
|
||||||
|
from .device import MySensorsChildEntity
|
||||||
from .helpers import on_unload
|
from .helpers import on_unload
|
||||||
|
|
||||||
|
|
||||||
@ -77,7 +78,7 @@ async def async_setup_entry(
|
|||||||
@callback
|
@callback
|
||||||
def async_discover(discovery_info: DiscoveryInfo) -> None:
|
def async_discover(discovery_info: DiscoveryInfo) -> None:
|
||||||
"""Discover and add a MySensors binary_sensor."""
|
"""Discover and add a MySensors binary_sensor."""
|
||||||
mysensors.setup_mysensors_platform(
|
setup_mysensors_platform(
|
||||||
hass,
|
hass,
|
||||||
Platform.BINARY_SENSOR,
|
Platform.BINARY_SENSOR,
|
||||||
discovery_info,
|
discovery_info,
|
||||||
@ -96,7 +97,7 @@ async def async_setup_entry(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class MySensorsBinarySensor(mysensors.device.MySensorsChildEntity, BinarySensorEntity):
|
class MySensorsBinarySensor(MySensorsChildEntity, BinarySensorEntity):
|
||||||
"""Representation of a MySensors binary sensor child node."""
|
"""Representation of a MySensors binary sensor child node."""
|
||||||
|
|
||||||
entity_description: MySensorsBinarySensorDescription
|
entity_description: MySensorsBinarySensorDescription
|
||||||
|
@ -18,8 +18,9 @@ from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
|||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.util.unit_system import METRIC_SYSTEM
|
from homeassistant.util.unit_system import METRIC_SYSTEM
|
||||||
|
|
||||||
from .. import mysensors
|
from . import setup_mysensors_platform
|
||||||
from .const import MYSENSORS_DISCOVERY, DiscoveryInfo
|
from .const import MYSENSORS_DISCOVERY, DiscoveryInfo
|
||||||
|
from .device import MySensorsChildEntity
|
||||||
from .helpers import on_unload
|
from .helpers import on_unload
|
||||||
|
|
||||||
DICT_HA_TO_MYS = {
|
DICT_HA_TO_MYS = {
|
||||||
@ -48,7 +49,7 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
async def async_discover(discovery_info: DiscoveryInfo) -> None:
|
async def async_discover(discovery_info: DiscoveryInfo) -> None:
|
||||||
"""Discover and add a MySensors climate."""
|
"""Discover and add a MySensors climate."""
|
||||||
mysensors.setup_mysensors_platform(
|
setup_mysensors_platform(
|
||||||
hass,
|
hass,
|
||||||
Platform.CLIMATE,
|
Platform.CLIMATE,
|
||||||
discovery_info,
|
discovery_info,
|
||||||
@ -67,7 +68,7 @@ async def async_setup_entry(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class MySensorsHVAC(mysensors.device.MySensorsChildEntity, ClimateEntity):
|
class MySensorsHVAC(MySensorsChildEntity, ClimateEntity):
|
||||||
"""Representation of a MySensors HVAC."""
|
"""Representation of a MySensors HVAC."""
|
||||||
|
|
||||||
_attr_hvac_modes = OPERATION_LIST
|
_attr_hvac_modes = OPERATION_LIST
|
||||||
|
@ -12,8 +12,9 @@ from homeassistant.core import HomeAssistant
|
|||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from .. import mysensors
|
from . import setup_mysensors_platform
|
||||||
from .const import MYSENSORS_DISCOVERY, DiscoveryInfo
|
from .const import MYSENSORS_DISCOVERY, DiscoveryInfo
|
||||||
|
from .device import MySensorsChildEntity
|
||||||
from .helpers import on_unload
|
from .helpers import on_unload
|
||||||
|
|
||||||
|
|
||||||
@ -36,7 +37,7 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
async def async_discover(discovery_info: DiscoveryInfo) -> None:
|
async def async_discover(discovery_info: DiscoveryInfo) -> None:
|
||||||
"""Discover and add a MySensors cover."""
|
"""Discover and add a MySensors cover."""
|
||||||
mysensors.setup_mysensors_platform(
|
setup_mysensors_platform(
|
||||||
hass,
|
hass,
|
||||||
Platform.COVER,
|
Platform.COVER,
|
||||||
discovery_info,
|
discovery_info,
|
||||||
@ -55,7 +56,7 @@ async def async_setup_entry(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class MySensorsCover(mysensors.device.MySensorsChildEntity, CoverEntity):
|
class MySensorsCover(MySensorsChildEntity, CoverEntity):
|
||||||
"""Representation of the value of a MySensors Cover child node."""
|
"""Representation of the value of a MySensors Cover child node."""
|
||||||
|
|
||||||
def get_cover_state(self) -> CoverState:
|
def get_cover_state(self) -> CoverState:
|
||||||
|
@ -18,7 +18,7 @@ from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
|||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.util.color import rgb_hex_to_rgb_list
|
from homeassistant.util.color import rgb_hex_to_rgb_list
|
||||||
|
|
||||||
from .. import mysensors
|
from . import setup_mysensors_platform
|
||||||
from .const import MYSENSORS_DISCOVERY, DiscoveryInfo, SensorType
|
from .const import MYSENSORS_DISCOVERY, DiscoveryInfo, SensorType
|
||||||
from .device import MySensorsChildEntity
|
from .device import MySensorsChildEntity
|
||||||
from .helpers import on_unload
|
from .helpers import on_unload
|
||||||
@ -38,7 +38,7 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
async def async_discover(discovery_info: DiscoveryInfo) -> None:
|
async def async_discover(discovery_info: DiscoveryInfo) -> None:
|
||||||
"""Discover and add a MySensors light."""
|
"""Discover and add a MySensors light."""
|
||||||
mysensors.setup_mysensors_platform(
|
setup_mysensors_platform(
|
||||||
hass,
|
hass,
|
||||||
Platform.LIGHT,
|
Platform.LIGHT,
|
||||||
discovery_info,
|
discovery_info,
|
||||||
@ -57,7 +57,7 @@ async def async_setup_entry(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class MySensorsLight(mysensors.device.MySensorsChildEntity, LightEntity):
|
class MySensorsLight(MySensorsChildEntity, LightEntity):
|
||||||
"""Representation of a MySensors Light child node."""
|
"""Representation of a MySensors Light child node."""
|
||||||
|
|
||||||
def __init__(self, *args: Any) -> None:
|
def __init__(self, *args: Any) -> None:
|
||||||
|
@ -38,7 +38,7 @@ from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
|||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.util.unit_system import METRIC_SYSTEM
|
from homeassistant.util.unit_system import METRIC_SYSTEM
|
||||||
|
|
||||||
from .. import mysensors
|
from . import setup_mysensors_platform
|
||||||
from .const import (
|
from .const import (
|
||||||
ATTR_GATEWAY_ID,
|
ATTR_GATEWAY_ID,
|
||||||
ATTR_NODE_ID,
|
ATTR_NODE_ID,
|
||||||
@ -49,6 +49,7 @@ from .const import (
|
|||||||
DiscoveryInfo,
|
DiscoveryInfo,
|
||||||
NodeDiscoveryInfo,
|
NodeDiscoveryInfo,
|
||||||
)
|
)
|
||||||
|
from .device import MySensorNodeEntity, MySensorsChildEntity
|
||||||
from .helpers import on_unload
|
from .helpers import on_unload
|
||||||
|
|
||||||
SENSORS: dict[str, SensorEntityDescription] = {
|
SENSORS: dict[str, SensorEntityDescription] = {
|
||||||
@ -215,7 +216,7 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
async def async_discover(discovery_info: DiscoveryInfo) -> None:
|
async def async_discover(discovery_info: DiscoveryInfo) -> None:
|
||||||
"""Discover and add a MySensors sensor."""
|
"""Discover and add a MySensors sensor."""
|
||||||
mysensors.setup_mysensors_platform(
|
setup_mysensors_platform(
|
||||||
hass,
|
hass,
|
||||||
Platform.SENSOR,
|
Platform.SENSOR,
|
||||||
discovery_info,
|
discovery_info,
|
||||||
@ -252,7 +253,7 @@ async def async_setup_entry(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class MyBatterySensor(mysensors.device.MySensorNodeEntity, SensorEntity):
|
class MyBatterySensor(MySensorNodeEntity, SensorEntity):
|
||||||
"""Battery sensor of MySensors node."""
|
"""Battery sensor of MySensors node."""
|
||||||
|
|
||||||
_attr_device_class = SensorDeviceClass.BATTERY
|
_attr_device_class = SensorDeviceClass.BATTERY
|
||||||
@ -277,7 +278,7 @@ class MyBatterySensor(mysensors.device.MySensorNodeEntity, SensorEntity):
|
|||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
|
|
||||||
|
|
||||||
class MySensorsSensor(mysensors.device.MySensorsChildEntity, SensorEntity):
|
class MySensorsSensor(MySensorsChildEntity, SensorEntity):
|
||||||
"""Representation of a MySensors Sensor child node."""
|
"""Representation of a MySensors Sensor child node."""
|
||||||
|
|
||||||
_attr_force_update = True
|
_attr_force_update = True
|
||||||
|
@ -9,7 +9,7 @@ from homeassistant.core import HomeAssistant, callback
|
|||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from .. import mysensors
|
from . import setup_mysensors_platform
|
||||||
from .const import MYSENSORS_DISCOVERY, DiscoveryInfo
|
from .const import MYSENSORS_DISCOVERY, DiscoveryInfo
|
||||||
from .device import MySensorsChildEntity
|
from .device import MySensorsChildEntity
|
||||||
from .helpers import on_unload
|
from .helpers import on_unload
|
||||||
@ -25,7 +25,7 @@ async def async_setup_entry(
|
|||||||
@callback
|
@callback
|
||||||
def async_discover(discovery_info: DiscoveryInfo) -> None:
|
def async_discover(discovery_info: DiscoveryInfo) -> None:
|
||||||
"""Discover and add a MySensors text entity."""
|
"""Discover and add a MySensors text entity."""
|
||||||
mysensors.setup_mysensors_platform(
|
setup_mysensors_platform(
|
||||||
hass,
|
hass,
|
||||||
Platform.TEXT,
|
Platform.TEXT,
|
||||||
discovery_info,
|
discovery_info,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user