Skip to content

Commit

Permalink
Add current and voltage for plugs to switchbot_cloud (home-assistant#…
Browse files Browse the repository at this point in the history
…135458)

SwitchBot Cloud: Adding current and voltage for plugs
  • Loading branch information
SeraphicRav authored Jan 12, 2025
1 parent 61ea732 commit 559c411
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
2 changes: 2 additions & 0 deletions homeassistant/components/switchbot_cloud/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
23 changes: 19 additions & 4 deletions homeassistant/components/switchbot_cloud/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,27 @@
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,
Expand All @@ -100,8 +107,16 @@
),
"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,
Expand Down

0 comments on commit 559c411

Please sign in to comment.