mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Handle incorrect values reported by some Shelly devices (#55042)
This commit is contained in:
parent
43b8353566
commit
fd66120d6d
@ -1,7 +1,7 @@
|
|||||||
"""Binary sensor for Shelly."""
|
"""Binary sensor for Shelly."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Final
|
from typing import Final, cast
|
||||||
|
|
||||||
from homeassistant.components.binary_sensor import (
|
from homeassistant.components.binary_sensor import (
|
||||||
DEVICE_CLASS_CONNECTIVITY,
|
DEVICE_CLASS_CONNECTIVITY,
|
||||||
@ -46,7 +46,9 @@ SENSORS: Final = {
|
|||||||
name="Overpowering", device_class=DEVICE_CLASS_PROBLEM
|
name="Overpowering", device_class=DEVICE_CLASS_PROBLEM
|
||||||
),
|
),
|
||||||
("sensor", "dwIsOpened"): BlockAttributeDescription(
|
("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(
|
("sensor", "flood"): BlockAttributeDescription(
|
||||||
name="Flood", device_class=DEVICE_CLASS_MOISTURE
|
name="Flood", device_class=DEVICE_CLASS_MOISTURE
|
||||||
|
@ -40,6 +40,7 @@ SENSORS: Final = {
|
|||||||
device_class=sensor.DEVICE_CLASS_BATTERY,
|
device_class=sensor.DEVICE_CLASS_BATTERY,
|
||||||
state_class=sensor.STATE_CLASS_MEASUREMENT,
|
state_class=sensor.STATE_CLASS_MEASUREMENT,
|
||||||
removal_condition=lambda settings, _: settings.get("external_power") == 1,
|
removal_condition=lambda settings, _: settings.get("external_power") == 1,
|
||||||
|
available=lambda block: cast(bool, block.battery != -1),
|
||||||
),
|
),
|
||||||
("device", "deviceTemp"): BlockAttributeDescription(
|
("device", "deviceTemp"): BlockAttributeDescription(
|
||||||
name="Device Temperature",
|
name="Device Temperature",
|
||||||
@ -176,6 +177,7 @@ SENSORS: Final = {
|
|||||||
unit=LIGHT_LUX,
|
unit=LIGHT_LUX,
|
||||||
device_class=sensor.DEVICE_CLASS_ILLUMINANCE,
|
device_class=sensor.DEVICE_CLASS_ILLUMINANCE,
|
||||||
state_class=sensor.STATE_CLASS_MEASUREMENT,
|
state_class=sensor.STATE_CLASS_MEASUREMENT,
|
||||||
|
available=lambda block: cast(bool, block.luminosity != -1),
|
||||||
),
|
),
|
||||||
("sensor", "tilt"): BlockAttributeDescription(
|
("sensor", "tilt"): BlockAttributeDescription(
|
||||||
name="Tilt",
|
name="Tilt",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user