Use list comprehension in onewire sensor descriptions (#61157)
* Add 0-3 range to constants * Use list comprehension in sensor definitions Co-authored-by: epenet <epenet@users.noreply.github.com>pull/61200/head
parent
8cee47072d
commit
54d55fdf88
|
@ -40,6 +40,8 @@ from .const import (
|
||||||
CONF_NAMES,
|
CONF_NAMES,
|
||||||
CONF_TYPE_OWSERVER,
|
CONF_TYPE_OWSERVER,
|
||||||
CONF_TYPE_SYSBUS,
|
CONF_TYPE_SYSBUS,
|
||||||
|
DEVICE_KEYS_0_3,
|
||||||
|
DEVICE_KEYS_A_B,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
READ_MODE_FLOAT,
|
READ_MODE_FLOAT,
|
||||||
READ_MODE_INT,
|
READ_MODE_INT,
|
||||||
|
@ -188,21 +190,15 @@ DEVICE_SENSORS: dict[str, tuple[OneWireSensorEntityDescription, ...]] = {
|
||||||
"28": (SIMPLE_TEMPERATURE_SENSOR_DESCRIPTION,),
|
"28": (SIMPLE_TEMPERATURE_SENSOR_DESCRIPTION,),
|
||||||
"3B": (SIMPLE_TEMPERATURE_SENSOR_DESCRIPTION,),
|
"3B": (SIMPLE_TEMPERATURE_SENSOR_DESCRIPTION,),
|
||||||
"42": (SIMPLE_TEMPERATURE_SENSOR_DESCRIPTION,),
|
"42": (SIMPLE_TEMPERATURE_SENSOR_DESCRIPTION,),
|
||||||
"1D": (
|
"1D": tuple(
|
||||||
OneWireSensorEntityDescription(
|
OneWireSensorEntityDescription(
|
||||||
key="counter.A",
|
key=f"counter.{id}",
|
||||||
name="Counter A",
|
name=f"Counter {id}",
|
||||||
native_unit_of_measurement="count",
|
native_unit_of_measurement="count",
|
||||||
read_mode=READ_MODE_INT,
|
read_mode=READ_MODE_INT,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
)
|
||||||
OneWireSensorEntityDescription(
|
for id in DEVICE_KEYS_A_B
|
||||||
key="counter.B",
|
|
||||||
name="Counter B",
|
|
||||||
native_unit_of_measurement="count",
|
|
||||||
read_mode=READ_MODE_INT,
|
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,39 +233,16 @@ HOBBYBOARD_EF: dict[str, tuple[OneWireSensorEntityDescription, ...]] = {
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
"HB_MOISTURE_METER": (
|
"HB_MOISTURE_METER": tuple(
|
||||||
OneWireSensorEntityDescription(
|
OneWireSensorEntityDescription(
|
||||||
key="moisture/sensor.0",
|
key=f"moisture/sensor.{id}",
|
||||||
device_class=SensorDeviceClass.PRESSURE,
|
device_class=SensorDeviceClass.PRESSURE,
|
||||||
name="Moisture 0",
|
name=f"Moisture {id}",
|
||||||
native_unit_of_measurement=PRESSURE_CBAR,
|
native_unit_of_measurement=PRESSURE_CBAR,
|
||||||
read_mode=READ_MODE_FLOAT,
|
read_mode=READ_MODE_FLOAT,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
)
|
||||||
OneWireSensorEntityDescription(
|
for id in DEVICE_KEYS_0_3
|
||||||
key="moisture/sensor.1",
|
|
||||||
device_class=SensorDeviceClass.PRESSURE,
|
|
||||||
name="Moisture 1",
|
|
||||||
native_unit_of_measurement=PRESSURE_CBAR,
|
|
||||||
read_mode=READ_MODE_FLOAT,
|
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
|
||||||
),
|
|
||||||
OneWireSensorEntityDescription(
|
|
||||||
key="moisture/sensor.2",
|
|
||||||
device_class=SensorDeviceClass.PRESSURE,
|
|
||||||
name="Moisture 2",
|
|
||||||
native_unit_of_measurement=PRESSURE_CBAR,
|
|
||||||
read_mode=READ_MODE_FLOAT,
|
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
|
||||||
),
|
|
||||||
OneWireSensorEntityDescription(
|
|
||||||
key="moisture/sensor.3",
|
|
||||||
device_class=SensorDeviceClass.PRESSURE,
|
|
||||||
name="Moisture 3",
|
|
||||||
native_unit_of_measurement=PRESSURE_CBAR,
|
|
||||||
read_mode=READ_MODE_FLOAT,
|
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue