mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Use GAS device class in smartthings (#83658)
This commit is contained in:
parent
c196fefe31
commit
f53145c540
@ -16,15 +16,14 @@ from homeassistant.config_entries import ConfigEntry
|
|||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
AREA_SQUARE_METERS,
|
AREA_SQUARE_METERS,
|
||||||
CONCENTRATION_PARTS_PER_MILLION,
|
CONCENTRATION_PARTS_PER_MILLION,
|
||||||
ELECTRIC_POTENTIAL_VOLT,
|
|
||||||
ENERGY_KILO_WATT_HOUR,
|
|
||||||
LIGHT_LUX,
|
LIGHT_LUX,
|
||||||
MASS_KILOGRAMS,
|
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
POWER_WATT,
|
UnitOfElectricPotential,
|
||||||
TEMP_CELSIUS,
|
UnitOfEnergy,
|
||||||
TEMP_FAHRENHEIT,
|
UnitOfMass,
|
||||||
VOLUME_CUBIC_METERS,
|
UnitOfPower,
|
||||||
|
UnitOfTemperature,
|
||||||
|
UnitOfVolume,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity import EntityCategory
|
from homeassistant.helpers.entity import EntityCategory
|
||||||
@ -87,7 +86,7 @@ CAPABILITY_TO_SENSORS: dict[str, list[Map]] = {
|
|||||||
Map(
|
Map(
|
||||||
Attribute.bmi_measurement,
|
Attribute.bmi_measurement,
|
||||||
"Body Mass Index",
|
"Body Mass Index",
|
||||||
f"{MASS_KILOGRAMS}/{AREA_SQUARE_METERS}",
|
f"{UnitOfMass.KILOGRAMS}/{AREA_SQUARE_METERS}",
|
||||||
None,
|
None,
|
||||||
SensorStateClass.MEASUREMENT,
|
SensorStateClass.MEASUREMENT,
|
||||||
None,
|
None,
|
||||||
@ -97,7 +96,7 @@ CAPABILITY_TO_SENSORS: dict[str, list[Map]] = {
|
|||||||
Map(
|
Map(
|
||||||
Attribute.body_weight_measurement,
|
Attribute.body_weight_measurement,
|
||||||
"Body Weight",
|
"Body Weight",
|
||||||
MASS_KILOGRAMS,
|
UnitOfMass.KILOGRAMS,
|
||||||
SensorDeviceClass.WEIGHT,
|
SensorDeviceClass.WEIGHT,
|
||||||
SensorStateClass.MEASUREMENT,
|
SensorStateClass.MEASUREMENT,
|
||||||
None,
|
None,
|
||||||
@ -198,7 +197,7 @@ CAPABILITY_TO_SENSORS: dict[str, list[Map]] = {
|
|||||||
Map(
|
Map(
|
||||||
Attribute.energy,
|
Attribute.energy,
|
||||||
"Energy Meter",
|
"Energy Meter",
|
||||||
ENERGY_KILO_WATT_HOUR,
|
UnitOfEnergy.KILO_WATT_HOUR,
|
||||||
SensorDeviceClass.ENERGY,
|
SensorDeviceClass.ENERGY,
|
||||||
SensorStateClass.TOTAL_INCREASING,
|
SensorStateClass.TOTAL_INCREASING,
|
||||||
None,
|
None,
|
||||||
@ -228,7 +227,7 @@ CAPABILITY_TO_SENSORS: dict[str, list[Map]] = {
|
|||||||
Map(
|
Map(
|
||||||
Attribute.gas_meter,
|
Attribute.gas_meter,
|
||||||
"Gas Meter",
|
"Gas Meter",
|
||||||
ENERGY_KILO_WATT_HOUR,
|
UnitOfEnergy.KILO_WATT_HOUR,
|
||||||
SensorDeviceClass.ENERGY,
|
SensorDeviceClass.ENERGY,
|
||||||
SensorStateClass.MEASUREMENT,
|
SensorStateClass.MEASUREMENT,
|
||||||
None,
|
None,
|
||||||
@ -247,8 +246,8 @@ CAPABILITY_TO_SENSORS: dict[str, list[Map]] = {
|
|||||||
Map(
|
Map(
|
||||||
Attribute.gas_meter_volume,
|
Attribute.gas_meter_volume,
|
||||||
"Gas Meter Volume",
|
"Gas Meter Volume",
|
||||||
VOLUME_CUBIC_METERS,
|
UnitOfVolume.CUBIC_METERS,
|
||||||
SensorDeviceClass.VOLUME,
|
SensorDeviceClass.GAS,
|
||||||
SensorStateClass.MEASUREMENT,
|
SensorStateClass.MEASUREMENT,
|
||||||
None,
|
None,
|
||||||
),
|
),
|
||||||
@ -320,7 +319,7 @@ CAPABILITY_TO_SENSORS: dict[str, list[Map]] = {
|
|||||||
Map(
|
Map(
|
||||||
Attribute.power,
|
Attribute.power,
|
||||||
"Power Meter",
|
"Power Meter",
|
||||||
POWER_WATT,
|
UnitOfPower.WATT,
|
||||||
SensorDeviceClass.POWER,
|
SensorDeviceClass.POWER,
|
||||||
SensorStateClass.MEASUREMENT,
|
SensorStateClass.MEASUREMENT,
|
||||||
None,
|
None,
|
||||||
@ -506,7 +505,7 @@ CAPABILITY_TO_SENSORS: dict[str, list[Map]] = {
|
|||||||
Map(
|
Map(
|
||||||
Attribute.voltage,
|
Attribute.voltage,
|
||||||
"Voltage Measurement",
|
"Voltage Measurement",
|
||||||
ELECTRIC_POTENTIAL_VOLT,
|
UnitOfElectricPotential.VOLT,
|
||||||
SensorDeviceClass.VOLTAGE,
|
SensorDeviceClass.VOLTAGE,
|
||||||
SensorStateClass.MEASUREMENT,
|
SensorStateClass.MEASUREMENT,
|
||||||
None,
|
None,
|
||||||
@ -536,7 +535,7 @@ CAPABILITY_TO_SENSORS: dict[str, list[Map]] = {
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
UNITS = {"C": TEMP_CELSIUS, "F": TEMP_FAHRENHEIT}
|
UNITS = {"C": UnitOfTemperature.CELSIUS, "F": UnitOfTemperature.FAHRENHEIT}
|
||||||
|
|
||||||
THREE_AXIS_NAMES = ["X Coordinate", "Y Coordinate", "Z Coordinate"]
|
THREE_AXIS_NAMES = ["X Coordinate", "Y Coordinate", "Z Coordinate"]
|
||||||
POWER_CONSUMPTION_REPORT_NAMES = [
|
POWER_CONSUMPTION_REPORT_NAMES = [
|
||||||
@ -745,8 +744,8 @@ class SmartThingsPowerConsumptionSensor(SmartThingsEntity, SensorEntity):
|
|||||||
def native_unit_of_measurement(self):
|
def native_unit_of_measurement(self):
|
||||||
"""Return the unit this state is expressed in."""
|
"""Return the unit this state is expressed in."""
|
||||||
if self.report_name == "power":
|
if self.report_name == "power":
|
||||||
return POWER_WATT
|
return UnitOfPower.WATT
|
||||||
return ENERGY_KILO_WATT_HOUR
|
return UnitOfEnergy.KILO_WATT_HOUR
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def extra_state_attributes(self):
|
def extra_state_attributes(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user