Migrate Nettigo Air Monitor to new entity naming style (#74993)
This commit is contained in:
parent
fa51a39f1d
commit
e1e85caf18
4 changed files with 203 additions and 180 deletions
|
@ -30,7 +30,6 @@ from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, Upda
|
||||||
from .const import (
|
from .const import (
|
||||||
ATTR_SDS011,
|
ATTR_SDS011,
|
||||||
ATTR_SPS30,
|
ATTR_SPS30,
|
||||||
DEFAULT_NAME,
|
|
||||||
DEFAULT_UPDATE_INTERVAL,
|
DEFAULT_UPDATE_INTERVAL,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
MANUFACTURER,
|
MANUFACTURER,
|
||||||
|
@ -130,7 +129,7 @@ class NAMDataUpdateCoordinator(DataUpdateCoordinator):
|
||||||
"""Return the device info."""
|
"""Return the device info."""
|
||||||
return DeviceInfo(
|
return DeviceInfo(
|
||||||
connections={(CONNECTION_NETWORK_MAC, cast(str, self._unique_id))},
|
connections={(CONNECTION_NETWORK_MAC, cast(str, self._unique_id))},
|
||||||
name=DEFAULT_NAME,
|
name="Nettigo Air Monitor",
|
||||||
sw_version=self.nam.software_version,
|
sw_version=self.nam.software_version,
|
||||||
manufacturer=MANUFACTURER,
|
manufacturer=MANUFACTURER,
|
||||||
configuration_url=f"http://{self.nam.host}/",
|
configuration_url=f"http://{self.nam.host}/",
|
||||||
|
|
|
@ -15,7 +15,7 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||||
|
|
||||||
from . import NAMDataUpdateCoordinator
|
from . import NAMDataUpdateCoordinator
|
||||||
from .const import DEFAULT_NAME, DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
PARALLEL_UPDATES = 1
|
PARALLEL_UPDATES = 1
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ _LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
RESTART_BUTTON: ButtonEntityDescription = ButtonEntityDescription(
|
RESTART_BUTTON: ButtonEntityDescription = ButtonEntityDescription(
|
||||||
key="restart",
|
key="restart",
|
||||||
name=f"{DEFAULT_NAME} Restart",
|
name="Restart",
|
||||||
device_class=ButtonDeviceClass.RESTART,
|
device_class=ButtonDeviceClass.RESTART,
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
)
|
)
|
||||||
|
@ -44,6 +44,8 @@ async def async_setup_entry(
|
||||||
class NAMButton(CoordinatorEntity[NAMDataUpdateCoordinator], ButtonEntity):
|
class NAMButton(CoordinatorEntity[NAMDataUpdateCoordinator], ButtonEntity):
|
||||||
"""Define an Nettigo Air Monitor button."""
|
"""Define an Nettigo Air Monitor button."""
|
||||||
|
|
||||||
|
_attr_has_entity_name = True
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
coordinator: NAMDataUpdateCoordinator,
|
coordinator: NAMDataUpdateCoordinator,
|
||||||
|
|
|
@ -4,21 +4,6 @@ from __future__ import annotations
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from typing import Final
|
from typing import Final
|
||||||
|
|
||||||
from homeassistant.components.sensor import (
|
|
||||||
SensorDeviceClass,
|
|
||||||
SensorEntityDescription,
|
|
||||||
SensorStateClass,
|
|
||||||
)
|
|
||||||
from homeassistant.const import (
|
|
||||||
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
|
||||||
CONCENTRATION_PARTS_PER_MILLION,
|
|
||||||
PERCENTAGE,
|
|
||||||
PRESSURE_HPA,
|
|
||||||
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
|
||||||
TEMP_CELSIUS,
|
|
||||||
)
|
|
||||||
from homeassistant.helpers.entity import EntityCategory
|
|
||||||
|
|
||||||
SUFFIX_P0: Final = "_p0"
|
SUFFIX_P0: Final = "_p0"
|
||||||
SUFFIX_P1: Final = "_p1"
|
SUFFIX_P1: Final = "_p1"
|
||||||
SUFFIX_P2: Final = "_p2"
|
SUFFIX_P2: Final = "_p2"
|
||||||
|
@ -49,7 +34,6 @@ ATTR_SPS30_P2: Final = f"{ATTR_SPS30}{SUFFIX_P2}"
|
||||||
ATTR_SPS30_P4: Final = f"{ATTR_SPS30}{SUFFIX_P4}"
|
ATTR_SPS30_P4: Final = f"{ATTR_SPS30}{SUFFIX_P4}"
|
||||||
ATTR_UPTIME: Final = "uptime"
|
ATTR_UPTIME: Final = "uptime"
|
||||||
|
|
||||||
DEFAULT_NAME: Final = "Nettigo Air Monitor"
|
|
||||||
DEFAULT_UPDATE_INTERVAL: Final = timedelta(minutes=6)
|
DEFAULT_UPDATE_INTERVAL: Final = timedelta(minutes=6)
|
||||||
DOMAIN: Final = "nam"
|
DOMAIN: Final = "nam"
|
||||||
MANUFACTURER: Final = "Nettigo"
|
MANUFACTURER: Final = "Nettigo"
|
||||||
|
@ -58,162 +42,3 @@ MIGRATION_SENSORS: Final = [
|
||||||
("temperature", ATTR_DHT22_TEMPERATURE),
|
("temperature", ATTR_DHT22_TEMPERATURE),
|
||||||
("humidity", ATTR_DHT22_HUMIDITY),
|
("humidity", ATTR_DHT22_HUMIDITY),
|
||||||
]
|
]
|
||||||
|
|
||||||
SENSORS: Final[tuple[SensorEntityDescription, ...]] = (
|
|
||||||
SensorEntityDescription(
|
|
||||||
key=ATTR_BME280_HUMIDITY,
|
|
||||||
name=f"{DEFAULT_NAME} BME280 Humidity",
|
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
|
||||||
device_class=SensorDeviceClass.HUMIDITY,
|
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
|
||||||
),
|
|
||||||
SensorEntityDescription(
|
|
||||||
key=ATTR_BME280_PRESSURE,
|
|
||||||
name=f"{DEFAULT_NAME} BME280 Pressure",
|
|
||||||
native_unit_of_measurement=PRESSURE_HPA,
|
|
||||||
device_class=SensorDeviceClass.PRESSURE,
|
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
|
||||||
),
|
|
||||||
SensorEntityDescription(
|
|
||||||
key=ATTR_BME280_TEMPERATURE,
|
|
||||||
name=f"{DEFAULT_NAME} BME280 Temperature",
|
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
|
||||||
),
|
|
||||||
SensorEntityDescription(
|
|
||||||
key=ATTR_BMP180_PRESSURE,
|
|
||||||
name=f"{DEFAULT_NAME} BMP180 Pressure",
|
|
||||||
native_unit_of_measurement=PRESSURE_HPA,
|
|
||||||
device_class=SensorDeviceClass.PRESSURE,
|
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
|
||||||
),
|
|
||||||
SensorEntityDescription(
|
|
||||||
key=ATTR_BMP180_TEMPERATURE,
|
|
||||||
name=f"{DEFAULT_NAME} BMP180 Temperature",
|
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
|
||||||
),
|
|
||||||
SensorEntityDescription(
|
|
||||||
key=ATTR_BMP280_PRESSURE,
|
|
||||||
name=f"{DEFAULT_NAME} BMP280 Pressure",
|
|
||||||
native_unit_of_measurement=PRESSURE_HPA,
|
|
||||||
device_class=SensorDeviceClass.PRESSURE,
|
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
|
||||||
),
|
|
||||||
SensorEntityDescription(
|
|
||||||
key=ATTR_BMP280_TEMPERATURE,
|
|
||||||
name=f"{DEFAULT_NAME} BMP280 Temperature",
|
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
|
||||||
),
|
|
||||||
SensorEntityDescription(
|
|
||||||
key=ATTR_HECA_HUMIDITY,
|
|
||||||
name=f"{DEFAULT_NAME} HECA Humidity",
|
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
|
||||||
device_class=SensorDeviceClass.HUMIDITY,
|
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
|
||||||
),
|
|
||||||
SensorEntityDescription(
|
|
||||||
key=ATTR_HECA_TEMPERATURE,
|
|
||||||
name=f"{DEFAULT_NAME} HECA Temperature",
|
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
|
||||||
),
|
|
||||||
SensorEntityDescription(
|
|
||||||
key=ATTR_MHZ14A_CARBON_DIOXIDE,
|
|
||||||
name=f"{DEFAULT_NAME} MH-Z14A Carbon Dioxide",
|
|
||||||
native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION,
|
|
||||||
device_class=SensorDeviceClass.CO2,
|
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
|
||||||
),
|
|
||||||
SensorEntityDescription(
|
|
||||||
key=ATTR_SDS011_P1,
|
|
||||||
name=f"{DEFAULT_NAME} SDS011 Particulate Matter 10",
|
|
||||||
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
|
||||||
device_class=SensorDeviceClass.PM10,
|
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
|
||||||
),
|
|
||||||
SensorEntityDescription(
|
|
||||||
key=ATTR_SDS011_P2,
|
|
||||||
name=f"{DEFAULT_NAME} SDS011 Particulate Matter 2.5",
|
|
||||||
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
|
||||||
device_class=SensorDeviceClass.PM25,
|
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
|
||||||
),
|
|
||||||
SensorEntityDescription(
|
|
||||||
key=ATTR_SHT3X_HUMIDITY,
|
|
||||||
name=f"{DEFAULT_NAME} SHT3X Humidity",
|
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
|
||||||
device_class=SensorDeviceClass.HUMIDITY,
|
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
|
||||||
),
|
|
||||||
SensorEntityDescription(
|
|
||||||
key=ATTR_SHT3X_TEMPERATURE,
|
|
||||||
name=f"{DEFAULT_NAME} SHT3X Temperature",
|
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
|
||||||
),
|
|
||||||
SensorEntityDescription(
|
|
||||||
key=ATTR_SPS30_P0,
|
|
||||||
name=f"{DEFAULT_NAME} SPS30 Particulate Matter 1.0",
|
|
||||||
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
|
||||||
device_class=SensorDeviceClass.PM1,
|
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
|
||||||
),
|
|
||||||
SensorEntityDescription(
|
|
||||||
key=ATTR_SPS30_P1,
|
|
||||||
name=f"{DEFAULT_NAME} SPS30 Particulate Matter 10",
|
|
||||||
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
|
||||||
device_class=SensorDeviceClass.PM10,
|
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
|
||||||
),
|
|
||||||
SensorEntityDescription(
|
|
||||||
key=ATTR_SPS30_P2,
|
|
||||||
name=f"{DEFAULT_NAME} SPS30 Particulate Matter 2.5",
|
|
||||||
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
|
||||||
device_class=SensorDeviceClass.PM25,
|
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
|
||||||
),
|
|
||||||
SensorEntityDescription(
|
|
||||||
key=ATTR_SPS30_P4,
|
|
||||||
name=f"{DEFAULT_NAME} SPS30 Particulate Matter 4.0",
|
|
||||||
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
|
||||||
icon="mdi:molecule",
|
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
|
||||||
),
|
|
||||||
SensorEntityDescription(
|
|
||||||
key=ATTR_DHT22_HUMIDITY,
|
|
||||||
name=f"{DEFAULT_NAME} DHT22 Humidity",
|
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
|
||||||
device_class=SensorDeviceClass.HUMIDITY,
|
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
|
||||||
),
|
|
||||||
SensorEntityDescription(
|
|
||||||
key=ATTR_DHT22_TEMPERATURE,
|
|
||||||
name=f"{DEFAULT_NAME} DHT22 Temperature",
|
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
|
||||||
),
|
|
||||||
SensorEntityDescription(
|
|
||||||
key=ATTR_SIGNAL_STRENGTH,
|
|
||||||
name=f"{DEFAULT_NAME} Signal Strength",
|
|
||||||
native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
|
||||||
device_class=SensorDeviceClass.SIGNAL_STRENGTH,
|
|
||||||
entity_registry_enabled_default=False,
|
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
|
||||||
),
|
|
||||||
SensorEntityDescription(
|
|
||||||
key=ATTR_UPTIME,
|
|
||||||
name=f"{DEFAULT_NAME} Uptime",
|
|
||||||
device_class=SensorDeviceClass.TIMESTAMP,
|
|
||||||
entity_registry_enabled_default=False,
|
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
|
@ -7,24 +7,219 @@ from typing import cast
|
||||||
|
|
||||||
from homeassistant.components.sensor import (
|
from homeassistant.components.sensor import (
|
||||||
DOMAIN as PLATFORM,
|
DOMAIN as PLATFORM,
|
||||||
|
SensorDeviceClass,
|
||||||
SensorEntity,
|
SensorEntity,
|
||||||
SensorEntityDescription,
|
SensorEntityDescription,
|
||||||
|
SensorStateClass,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
from homeassistant.const import (
|
||||||
|
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
||||||
|
CONCENTRATION_PARTS_PER_MILLION,
|
||||||
|
PERCENTAGE,
|
||||||
|
PRESSURE_HPA,
|
||||||
|
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
||||||
|
TEMP_CELSIUS,
|
||||||
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import entity_registry
|
from homeassistant.helpers import entity_registry
|
||||||
|
from homeassistant.helpers.entity import EntityCategory
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.typing import StateType
|
from homeassistant.helpers.typing import StateType
|
||||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||||
from homeassistant.util.dt import utcnow
|
from homeassistant.util.dt import utcnow
|
||||||
|
|
||||||
from . import NAMDataUpdateCoordinator
|
from . import NAMDataUpdateCoordinator
|
||||||
from .const import ATTR_UPTIME, DOMAIN, MIGRATION_SENSORS, SENSORS
|
from .const import (
|
||||||
|
ATTR_BME280_HUMIDITY,
|
||||||
|
ATTR_BME280_PRESSURE,
|
||||||
|
ATTR_BME280_TEMPERATURE,
|
||||||
|
ATTR_BMP180_PRESSURE,
|
||||||
|
ATTR_BMP180_TEMPERATURE,
|
||||||
|
ATTR_BMP280_PRESSURE,
|
||||||
|
ATTR_BMP280_TEMPERATURE,
|
||||||
|
ATTR_DHT22_HUMIDITY,
|
||||||
|
ATTR_DHT22_TEMPERATURE,
|
||||||
|
ATTR_HECA_HUMIDITY,
|
||||||
|
ATTR_HECA_TEMPERATURE,
|
||||||
|
ATTR_MHZ14A_CARBON_DIOXIDE,
|
||||||
|
ATTR_SDS011_P1,
|
||||||
|
ATTR_SDS011_P2,
|
||||||
|
ATTR_SHT3X_HUMIDITY,
|
||||||
|
ATTR_SHT3X_TEMPERATURE,
|
||||||
|
ATTR_SIGNAL_STRENGTH,
|
||||||
|
ATTR_SPS30_P0,
|
||||||
|
ATTR_SPS30_P1,
|
||||||
|
ATTR_SPS30_P2,
|
||||||
|
ATTR_SPS30_P4,
|
||||||
|
ATTR_UPTIME,
|
||||||
|
DOMAIN,
|
||||||
|
MIGRATION_SENSORS,
|
||||||
|
)
|
||||||
|
|
||||||
PARALLEL_UPDATES = 1
|
PARALLEL_UPDATES = 1
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
SENSORS: tuple[SensorEntityDescription, ...] = (
|
||||||
|
SensorEntityDescription(
|
||||||
|
key=ATTR_BME280_HUMIDITY,
|
||||||
|
name="BME280 humidity",
|
||||||
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
|
device_class=SensorDeviceClass.HUMIDITY,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
),
|
||||||
|
SensorEntityDescription(
|
||||||
|
key=ATTR_BME280_PRESSURE,
|
||||||
|
name="BME280 pressure",
|
||||||
|
native_unit_of_measurement=PRESSURE_HPA,
|
||||||
|
device_class=SensorDeviceClass.PRESSURE,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
),
|
||||||
|
SensorEntityDescription(
|
||||||
|
key=ATTR_BME280_TEMPERATURE,
|
||||||
|
name="BME280 temperature",
|
||||||
|
native_unit_of_measurement=TEMP_CELSIUS,
|
||||||
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
),
|
||||||
|
SensorEntityDescription(
|
||||||
|
key=ATTR_BMP180_PRESSURE,
|
||||||
|
name="BMP180 pressure",
|
||||||
|
native_unit_of_measurement=PRESSURE_HPA,
|
||||||
|
device_class=SensorDeviceClass.PRESSURE,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
),
|
||||||
|
SensorEntityDescription(
|
||||||
|
key=ATTR_BMP180_TEMPERATURE,
|
||||||
|
name="BMP180 temperature",
|
||||||
|
native_unit_of_measurement=TEMP_CELSIUS,
|
||||||
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
),
|
||||||
|
SensorEntityDescription(
|
||||||
|
key=ATTR_BMP280_PRESSURE,
|
||||||
|
name="BMP280 pressure",
|
||||||
|
native_unit_of_measurement=PRESSURE_HPA,
|
||||||
|
device_class=SensorDeviceClass.PRESSURE,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
),
|
||||||
|
SensorEntityDescription(
|
||||||
|
key=ATTR_BMP280_TEMPERATURE,
|
||||||
|
name="BMP280 temperature",
|
||||||
|
native_unit_of_measurement=TEMP_CELSIUS,
|
||||||
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
),
|
||||||
|
SensorEntityDescription(
|
||||||
|
key=ATTR_HECA_HUMIDITY,
|
||||||
|
name="HECA humidity",
|
||||||
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
|
device_class=SensorDeviceClass.HUMIDITY,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
),
|
||||||
|
SensorEntityDescription(
|
||||||
|
key=ATTR_HECA_TEMPERATURE,
|
||||||
|
name="HECA temperature",
|
||||||
|
native_unit_of_measurement=TEMP_CELSIUS,
|
||||||
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
),
|
||||||
|
SensorEntityDescription(
|
||||||
|
key=ATTR_MHZ14A_CARBON_DIOXIDE,
|
||||||
|
name="MH-Z14A carbon dioxide",
|
||||||
|
native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION,
|
||||||
|
device_class=SensorDeviceClass.CO2,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
),
|
||||||
|
SensorEntityDescription(
|
||||||
|
key=ATTR_SDS011_P1,
|
||||||
|
name="SDS011 particulate matter 10",
|
||||||
|
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
||||||
|
device_class=SensorDeviceClass.PM10,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
),
|
||||||
|
SensorEntityDescription(
|
||||||
|
key=ATTR_SDS011_P2,
|
||||||
|
name="SDS011 particulate matter 2.5",
|
||||||
|
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
||||||
|
device_class=SensorDeviceClass.PM25,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
),
|
||||||
|
SensorEntityDescription(
|
||||||
|
key=ATTR_SHT3X_HUMIDITY,
|
||||||
|
name="SHT3X humidity",
|
||||||
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
|
device_class=SensorDeviceClass.HUMIDITY,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
),
|
||||||
|
SensorEntityDescription(
|
||||||
|
key=ATTR_SHT3X_TEMPERATURE,
|
||||||
|
name="SHT3X temperature",
|
||||||
|
native_unit_of_measurement=TEMP_CELSIUS,
|
||||||
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
),
|
||||||
|
SensorEntityDescription(
|
||||||
|
key=ATTR_SPS30_P0,
|
||||||
|
name="SPS30 particulate matter 1.0",
|
||||||
|
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
||||||
|
device_class=SensorDeviceClass.PM1,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
),
|
||||||
|
SensorEntityDescription(
|
||||||
|
key=ATTR_SPS30_P1,
|
||||||
|
name="SPS30 particulate matter 10",
|
||||||
|
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
||||||
|
device_class=SensorDeviceClass.PM10,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
),
|
||||||
|
SensorEntityDescription(
|
||||||
|
key=ATTR_SPS30_P2,
|
||||||
|
name="SPS30 particulate matter 2.5",
|
||||||
|
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
||||||
|
device_class=SensorDeviceClass.PM25,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
),
|
||||||
|
SensorEntityDescription(
|
||||||
|
key=ATTR_SPS30_P4,
|
||||||
|
name="SPS30 particulate matter 4.0",
|
||||||
|
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
||||||
|
icon="mdi:molecule",
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
),
|
||||||
|
SensorEntityDescription(
|
||||||
|
key=ATTR_DHT22_HUMIDITY,
|
||||||
|
name="DHT22 humidity",
|
||||||
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
|
device_class=SensorDeviceClass.HUMIDITY,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
),
|
||||||
|
SensorEntityDescription(
|
||||||
|
key=ATTR_DHT22_TEMPERATURE,
|
||||||
|
name="DHT22 temperature",
|
||||||
|
native_unit_of_measurement=TEMP_CELSIUS,
|
||||||
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
),
|
||||||
|
SensorEntityDescription(
|
||||||
|
key=ATTR_SIGNAL_STRENGTH,
|
||||||
|
name="Signal strength",
|
||||||
|
native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
||||||
|
device_class=SensorDeviceClass.SIGNAL_STRENGTH,
|
||||||
|
entity_registry_enabled_default=False,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
|
),
|
||||||
|
SensorEntityDescription(
|
||||||
|
key=ATTR_UPTIME,
|
||||||
|
name="Uptime",
|
||||||
|
device_class=SensorDeviceClass.TIMESTAMP,
|
||||||
|
entity_registry_enabled_default=False,
|
||||||
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
||||||
|
@ -61,6 +256,8 @@ async def async_setup_entry(
|
||||||
class NAMSensor(CoordinatorEntity[NAMDataUpdateCoordinator], SensorEntity):
|
class NAMSensor(CoordinatorEntity[NAMDataUpdateCoordinator], SensorEntity):
|
||||||
"""Define an Nettigo Air Monitor sensor."""
|
"""Define an Nettigo Air Monitor sensor."""
|
||||||
|
|
||||||
|
_attr_has_entity_name = True
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
coordinator: NAMDataUpdateCoordinator,
|
coordinator: NAMDataUpdateCoordinator,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue