mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 09:47:13 +00:00
Broadlink, remove attr_current_power_w and add sensor (#53342)
This commit is contained in:
parent
37d6824ed4
commit
d58a02a647
@ -7,7 +7,16 @@ DOMAIN = "broadlink"
|
||||
|
||||
DOMAINS_AND_TYPES = {
|
||||
REMOTE_DOMAIN: {"RM4MINI", "RM4PRO", "RMMINI", "RMMINIB", "RMPRO"},
|
||||
SENSOR_DOMAIN: {"A1", "RM4MINI", "RM4PRO", "RMPRO"},
|
||||
SENSOR_DOMAIN: {
|
||||
"A1",
|
||||
"RM4MINI",
|
||||
"RM4PRO",
|
||||
"RMPRO",
|
||||
"SP2S",
|
||||
"SP3S",
|
||||
"SP4",
|
||||
"SP4B",
|
||||
},
|
||||
SWITCH_DOMAIN: {
|
||||
"BG1",
|
||||
"MP1",
|
||||
|
@ -6,12 +6,13 @@ import voluptuous as vol
|
||||
from homeassistant.components.sensor import (
|
||||
DEVICE_CLASS_HUMIDITY,
|
||||
DEVICE_CLASS_ILLUMINANCE,
|
||||
DEVICE_CLASS_POWER,
|
||||
DEVICE_CLASS_TEMPERATURE,
|
||||
PLATFORM_SCHEMA,
|
||||
STATE_CLASS_MEASUREMENT,
|
||||
SensorEntity,
|
||||
)
|
||||
from homeassistant.const import CONF_HOST, PERCENTAGE, TEMP_CELSIUS
|
||||
from homeassistant.const import CONF_HOST, PERCENTAGE, POWER_WATT, TEMP_CELSIUS
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
|
||||
@ -37,6 +38,12 @@ SENSOR_TYPES = {
|
||||
),
|
||||
"light": ("Light", None, DEVICE_CLASS_ILLUMINANCE, None),
|
||||
"noise": ("Noise", None, None, None),
|
||||
"power": (
|
||||
"Current power",
|
||||
POWER_WATT,
|
||||
DEVICE_CLASS_POWER,
|
||||
STATE_CLASS_MEASUREMENT,
|
||||
),
|
||||
}
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
|
@ -232,14 +232,12 @@ class BroadlinkSP2Switch(BroadlinkSP1Switch):
|
||||
"""Initialize the switch."""
|
||||
super().__init__(device, *args, **kwargs)
|
||||
self._attr_is_on = self._coordinator.data["pwr"]
|
||||
self._attr_current_power_w = self._coordinator.data.get("power")
|
||||
|
||||
@callback
|
||||
def update_data(self):
|
||||
"""Update data."""
|
||||
if self._coordinator.last_update_success:
|
||||
self._attr_is_on = self._coordinator.data["pwr"]
|
||||
self._attr_current_power_w = self._coordinator.data.get("power")
|
||||
self.async_write_ha_state()
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user