Add Senoro door sensor alarm #4155
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed change
This adds a binary sensor entity for the Senoro door sensor that displays the current alarm state.
A button entity is also added that allows for resetting an activated tamper alarm.
This still needs testing
Additional information
Follow-up to:
_TZE200_ytx9fudw
#4086Implementation details:
tuya_switch
(and so on) methods do three things: (1) map the Tuya DP to a ZCL attribute, (2) create that ZCL attribute, and (3) create the switch entity metadata. Here, we calltuya_dp_attribute
to (1) map the DP and (2) create the ZCL attribute. We callbinary_sensor
andwrite_attr_button
methods directly for the mapped ZCL attribute.translation_key
is omitted for the "Tamper" alarm, as we set the "tamper device class", defaulting to a translated "Tamper" name in Home Assistantunique_id_suffix
is only kind of needed for the binary sensor and button entity. The unique ID for the HA entities is based on theattribute_name
by default, which would conflict. However, unique IDs are still keyed by platform (binary_sensor
vsbutton
in ZHA), so they won't conflict for now. Still, we want to avoid this, so I've given them separateunique_id_suffix
es.Checklist
pre-commit
checks pass / the code has been formatted using Black