forked from home-assistant/core
Handle incorrect values reported by some Shelly devices (#55042)
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
"""Binary sensor for Shelly."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Final
|
||||
from typing import Final, cast
|
||||
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASS_CONNECTIVITY,
|
||||
@ -46,7 +46,9 @@ SENSORS: Final = {
|
||||
name="Overpowering", device_class=DEVICE_CLASS_PROBLEM
|
||||
),
|
||||
("sensor", "dwIsOpened"): BlockAttributeDescription(
|
||||
name="Door", device_class=DEVICE_CLASS_OPENING
|
||||
name="Door",
|
||||
device_class=DEVICE_CLASS_OPENING,
|
||||
available=lambda block: cast(bool, block.dwIsOpened != -1),
|
||||
),
|
||||
("sensor", "flood"): BlockAttributeDescription(
|
||||
name="Flood", device_class=DEVICE_CLASS_MOISTURE
|
||||
|
@ -40,6 +40,7 @@ SENSORS: Final = {
|
||||
device_class=sensor.DEVICE_CLASS_BATTERY,
|
||||
state_class=sensor.STATE_CLASS_MEASUREMENT,
|
||||
removal_condition=lambda settings, _: settings.get("external_power") == 1,
|
||||
available=lambda block: cast(bool, block.battery != -1),
|
||||
),
|
||||
("device", "deviceTemp"): BlockAttributeDescription(
|
||||
name="Device Temperature",
|
||||
@ -176,6 +177,7 @@ SENSORS: Final = {
|
||||
unit=LIGHT_LUX,
|
||||
device_class=sensor.DEVICE_CLASS_ILLUMINANCE,
|
||||
state_class=sensor.STATE_CLASS_MEASUREMENT,
|
||||
available=lambda block: cast(bool, block.luminosity != -1),
|
||||
),
|
||||
("sensor", "tilt"): BlockAttributeDescription(
|
||||
name="Tilt",
|
||||
|
Reference in New Issue
Block a user