Skip to content

Instantly share code, notes, and snippets.

@marlomgirardi
Last active February 21, 2026 08:08
Show Gist options
  • Select an option

  • Save marlomgirardi/4fca8e6097520727d6cf88056798a8de to your computer and use it in GitHub Desktop.

Select an option

Save marlomgirardi/4fca8e6097520727d6cf88056798a8de to your computer and use it in GitHub Desktop.
TS130F by _TZ3210_dwytrmda position fix
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:
- domain:
- cover
device_class:
- shutter
multiple: false
reorder: false
mode: restart
trigger:
- platform: state
entity_id: !input shutter_entity
attribute: current_position
id: stuck_1
to: "1"
for:
hours: 0
minutes: 0
seconds: 30
- platform: state
entity_id: !input shutter_entity
attribute: current_position
id: stuck_99
to: "99"
for:
hours: 0
minutes: 0
seconds: 30
- platform: state
entity_id: !input shutter_entity
id: stuck_opening
to: opening
for:
hours: 0
minutes: 1
seconds: 0
- platform: state
entity_id: !input shutter_entity
id: stuck_closing
to: closing
for:
hours: 0
minutes: 1
seconds: 0
- platform: state
entity_id: !input shutter_entity
attribute: current_position
condition:
# ✅ Ignore artificial 0 ⇄ 100 instant flips (HA 2026.2 bug behaviour)
- condition: template
value_template: >
{% set from_pos = trigger.from_state.attributes.current_position
if trigger.from_state is not none else none %}
{% set to_pos = trigger.to_state.attributes.current_position
if trigger.to_state is not none else none %}
{% if from_pos is not none and to_pos is not none %}
{{ not (
(from_pos | int == 100 and to_pos | int == 0) or
(from_pos | int == 0 and to_pos | int == 100)
) }}
{% else %}
true
{% endif %}
- 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 | first | default([],
true))[1] | default('') }}"
- alias: When multiple triggers, make sure only the last one runs
delay:
seconds: 5
- choose:
- 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 }}"
- 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:
- 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