Add current and voltage for plugs to switchbot_cloud (#135458)

SwitchBot Cloud: Adding current and voltage for plugs
This commit is contained in:
Ravaka Razafimanantsoa 2025-01-13 02:42:06 +09:00 committed by GitHub
parent 61ea732caa
commit 559c411dd2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 4 deletions

View File

@ -91,6 +91,8 @@ def make_device_data(
"MeterPro",
"MeterPro(CO2)",
"Relay Switch 1PM",
"Plug Mini (US)",
"Plug Mini (JP)",
]:
devices_data.sensors.append(
prepare_device(hass, api, device, coordinators_by_id)

View File

@ -61,20 +61,27 @@ POWER_DESCRIPTION = SensorEntityDescription(
native_unit_of_measurement=UnitOfPower.WATT,
)
VOLATGE_DESCRIPTION = SensorEntityDescription(
VOLTAGE_DESCRIPTION = SensorEntityDescription(
key=SENSOR_TYPE_VOLTAGE,
device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
)
CURRENT_DESCRIPTION = SensorEntityDescription(
CURRENT_DESCRIPTION_IN_MA = SensorEntityDescription(
key=SENSOR_TYPE_CURRENT,
device_class=SensorDeviceClass.CURRENT,
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfElectricCurrent.MILLIAMPERE,
)
CURRENT_DESCRIPTION_IN_A = SensorEntityDescription(
key=SENSOR_TYPE_CURRENT,
device_class=SensorDeviceClass.CURRENT,
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
)
CO2_DESCRIPTION = SensorEntityDescription(
key=SENSOR_TYPE_CO2,
device_class=SensorDeviceClass.CO2,
@ -100,8 +107,16 @@ SENSOR_DESCRIPTIONS_BY_DEVICE_TYPES = {
),
"Relay Switch 1PM": (
POWER_DESCRIPTION,
VOLATGE_DESCRIPTION,
CURRENT_DESCRIPTION,
VOLTAGE_DESCRIPTION,
CURRENT_DESCRIPTION_IN_MA,
),
"Plug Mini (US)": (
VOLTAGE_DESCRIPTION,
CURRENT_DESCRIPTION_IN_A,
),
"Plug Mini (JP)": (
VOLTAGE_DESCRIPTION,
CURRENT_DESCRIPTION_IN_A,
),
"Hub 2": (
TEMPERATURE_DESCRIPTION,