-
-
Notifications
You must be signed in to change notification settings - Fork 38k
YoLink Power Failure Alarm #91934
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
YoLink Power Failure Alarm #91934
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ | |
| ATTR_DEVICE_MOTION_SENSOR, | ||
| ATTR_DEVICE_MULTI_OUTLET, | ||
| ATTR_DEVICE_OUTLET, | ||
| ATTR_DEVICE_POWER_FAILURE_ALARM, | ||
| ATTR_DEVICE_SIREN, | ||
| ATTR_DEVICE_SMART_REMOTER, | ||
| ATTR_DEVICE_SWITCH, | ||
|
|
@@ -71,6 +72,7 @@ class YoLinkSensorEntityDescription( | |
| ATTR_DEVICE_MULTI_OUTLET, | ||
| ATTR_DEVICE_SMART_REMOTER, | ||
| ATTR_DEVICE_OUTLET, | ||
| ATTR_DEVICE_POWER_FAILURE_ALARM, | ||
| ATTR_DEVICE_SIREN, | ||
| ATTR_DEVICE_SWITCH, | ||
| ATTR_DEVICE_TH_SENSOR, | ||
|
|
@@ -86,6 +88,7 @@ class YoLinkSensorEntityDescription( | |
| ATTR_DEVICE_DOOR_SENSOR, | ||
| ATTR_DEVICE_LEAK_SENSOR, | ||
| ATTR_DEVICE_MOTION_SENSOR, | ||
| ATTR_DEVICE_POWER_FAILURE_ALARM, | ||
| ATTR_DEVICE_SMART_REMOTER, | ||
| ATTR_DEVICE_TH_SENSOR, | ||
| ATTR_DEVICE_VIBRATION_SENSOR, | ||
|
|
@@ -110,6 +113,14 @@ def cvt_battery(val: int | None) -> int | None: | |
| return 0 | ||
|
|
||
|
|
||
| def cvt_volume(val: int | None) -> str | None: | ||
| """Convert volume to string.""" | ||
| if val is None: | ||
| return None | ||
| volume_level = {1: "low", 2: "medium", 3: "high"} | ||
| return volume_level.get(val, None) | ||
|
|
||
|
|
||
| SENSOR_TYPES: tuple[YoLinkSensorEntityDescription, ...] = ( | ||
| YoLinkSensorEntityDescription( | ||
| key="battery", | ||
|
|
@@ -157,6 +168,41 @@ def cvt_battery(val: int | None) -> int | None: | |
| entity_registry_enabled_default=False, | ||
| should_update_entity=lambda value: value is not None, | ||
| ), | ||
| YoLinkSensorEntityDescription( | ||
| key="state", | ||
| device_class=SensorDeviceClass.ENUM, | ||
| name="State", | ||
| icon="mdi:flash", | ||
| options=["normal", "alert", "off"], | ||
| exists_fn=lambda device: device.device_type in ATTR_DEVICE_POWER_FAILURE_ALARM, | ||
| ), | ||
| YoLinkSensorEntityDescription( | ||
| key="mute", | ||
| device_class=SensorDeviceClass.ENUM, | ||
| name="Mute", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as above about this possibly being too vague |
||
| icon="mdi:volume-mute", | ||
| options=["yes", "no"], | ||
| exists_fn=lambda device: device.device_type in ATTR_DEVICE_POWER_FAILURE_ALARM, | ||
| value=lambda value: "yes" if value is True else "no", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this is not a control but a sensor, should the states be "muted" and "unmuted"?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a physical mute button on the device, This entity is used to show whether the device is in silent mode |
||
| ), | ||
| YoLinkSensorEntityDescription( | ||
| key="sound", | ||
| device_class=SensorDeviceClass.ENUM, | ||
| name="Volume", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as above about this possibly being too vague |
||
| icon="mdi:volume-high", | ||
| options=["low", "medium", "high"], | ||
| exists_fn=lambda device: device.device_type in ATTR_DEVICE_POWER_FAILURE_ALARM, | ||
| value=cvt_volume, | ||
| ), | ||
| YoLinkSensorEntityDescription( | ||
| key="beep", | ||
| device_class=SensorDeviceClass.ENUM, | ||
| name="Beep", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as above about this possibly being too vague |
||
| icon="mdi:bullhorn", | ||
| options=["enable", "disable"], | ||
| exists_fn=lambda device: device.device_type in ATTR_DEVICE_POWER_FAILURE_ALARM, | ||
| value=lambda value: "enable" if value is True else "disable", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this is not a control but a sensor, should the states be "enabled" and "disabled"?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Our API does not support change the settings of the beeper, but the mobile application can , this entity is used to display the status of the beeper |
||
| ), | ||
| ) | ||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a vague name, maybe name it "Power failure alarm"?