Last active
May 16, 2025 11:56
-
-
Save marlomgirardi/4fca8e6097520727d6cf88056798a8de to your computer and use it in GitHub Desktop.
TS130F by _TZ3210_dwytrmda position fix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
blueprint: | |
name: Shutter Position Fix | |
description: A fix for 'TS130F by _TZ3210_dwytrmda' position | |
domain: automation | |
source_url: https://gist.github.com/marlomgirardi/4fca8e6097520727d6cf88056798a8de#file-cover_position_fix-yaml | |
author: Marlom Girardi | |
input: | |
shutter_entity: | |
name: Shutter to be fixed | |
selector: | |
entity: | |
filter: | |
device_class: shutter | |
domain: cover | |
# If position is not set yet, cancel use the last trigger. | |
# Helps to keep the communication as little as possible. | |
mode: restart | |
# max_exceeded: silent | |
trigger: | |
# Either direct use of the switch or through home assistant. | |
# using open and close events do not work for phisical use. | |
- platform: state | |
entity_id: !input shutter_entity | |
attribute: current_position | |
# There are cases where the position gets stuck at 1, | |
- platform: state | |
entity_id: !input shutter_entity | |
attribute: current_position | |
id: stuck_1 | |
to: "1" | |
for: | |
hours: 0 | |
minutes: 0 | |
seconds: 30 | |
# There are cases where the position gets stuck at 99. | |
- platform: state | |
entity_id: !input shutter_entity | |
attribute: current_position | |
id: stuck_99 | |
to: "99" | |
for: | |
hours: 0 | |
minutes: 0 | |
seconds: 30 | |
# There are cases where the position is correct but HA state gets stuck at opening. | |
- platform: state | |
entity_id: !input shutter_entity | |
id: stuck_opening | |
to: opening | |
for: | |
hours: 0 | |
minutes: 1 | |
seconds: 0 | |
# There are cases where the position is correct but HA state gets stuck at closing. | |
- platform: state | |
entity_id: !input shutter_entity | |
id: stuck_closing | |
to: closing | |
for: | |
hours: 0 | |
minutes: 1 | |
seconds: 0 | |
condition: | |
# The position changes if the device gets unavailable, the call is unnecessary in that case. | |
# Only execute if it is between the logical range. | |
- condition: numeric_state | |
entity_id: !input shutter_entity | |
attribute: current_position | |
enabled: true | |
above: -1 | |
below: 101 | |
action: | |
- variables: | |
position: "{{ state_attr(trigger.entity_id, 'current_position') }}" | |
ieee: "{{ (device_attr(trigger.entity_id,'identifiers')|list).0.1 }}" | |
- choose: | |
# Force stop and set to 0 if stuck at 1% or closing | |
- conditions: | |
- condition: trigger | |
id: | |
- stuck_1 | |
- stuck_closing | |
sequence: | |
- data: | |
cluster_type: in | |
endpoint_id: 1 | |
cluster_id: 258 | |
attribute: 8 | |
value: "0" | |
ieee: "{{ ieee }}" | |
action: zha.set_zigbee_cluster_attribute | |
metadata: {} | |
alias: Force current position to 0 | |
- action: cover.stop_cover | |
metadata: {} | |
data: {} | |
target: | |
entity_id: "{{ trigger.entity_id }}" | |
# Force stop and set to 100 if stuck at 99% or closing | |
- conditions: | |
- condition: trigger | |
id: | |
- stuck_99 | |
- stuck_opening | |
sequence: | |
- data: | |
cluster_type: in | |
endpoint_id: 1 | |
cluster_id: 258 | |
attribute: 8 | |
value: "100" | |
ieee: "{{ ieee }}" | |
action: zha.set_zigbee_cluster_attribute | |
metadata: {} | |
alias: Force current position to 100 | |
- action: cover.stop_cover | |
metadata: {} | |
data: {} | |
target: | |
entity_id: "{{ trigger.entity_id }}" | |
default: | |
- delay: | |
seconds: 5 | |
alias: When multiple triggers, make sure only the last one runs | |
- data: | |
cluster_type: in | |
endpoint_id: 1 | |
cluster_id: 258 | |
attribute: 8 | |
value: "{{ position }}" | |
ieee: "{{ ieee }}" | |
action: zha.set_zigbee_cluster_attribute | |
metadata: {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment