Hi, I have following automation that monitor event and trigger every minute to set, value of an input text.
The input text is used to modify caracteristics of a button (style, icon, etc.).
Every thing it’s working great, but I noticed that in every check, done every minute, state of “input_text.stato_scanning_bt_proxy_1” is reset to “spento” for a while, then set to “acceso” almost immediately (just because is “acceso”).
That’s causing that for a while my button style, icon and so on changing and come back to “real status” should be.
Any idea to fix it?
AUTOMATION:
> alias: BT Scanning Status - esp32-bluetooth-proxy-1
> description: ""
> trigger:
> - platform: event
> event_type: esphome.ble_scanning_state
> - platform: time_pattern
> minutes: /1
> action:
> - data_template:
> entity_id: input_text.stato_scanning_bt_proxy_1
> value: >
> {% if trigger.event is defined and trigger.event.data.status == 'acceso'
> %}
> acceso
> {% else %}
> spento
> {% endif %}
> action: input_text.set_value
BUTTON:
type: custom:button-card
show_entity_picture: true
entity: input_text.stato_scanning_bt_proxy_1
icon: mdi:bluetooth
show_state: false
show_label: true
show_name: true
show_icon: true
tap_action:
confirmation:
text: Confermi il cambio di stato ?
action: call-service
service: |
[[[
if (states['input_text.stato_scanning_bt_proxy_1'].state === 'acceso')
return 'button.press';
else
return 'button.press';
]]]
service_data:
entity_id: |
[[[
if (states['input_text.stato_scanning_bt_proxy_1'].state === 'spento')
return 'button.esp32_bluetooth_proxy_1_start_scan_esp32_bt_proxy_1';
else
return 'button.esp32_bluetooth_proxy_1_stop_scan_esp32_bt_proxy_1';
]]]
size: 40%
name: Stato Tracking BT
label: |
[[[
if (states['input_text.stato_scanning_bt_proxy_1'].state === "acceso")
return "ACCESO";
else if (states['input_text.stato_scanning_bt_proxy_1'].state === "spento")
return "SPENTO";
]]]
styles:
card:
- padding: 5px 15px
- background: linear-gradient(rgba(255,255,255,0.1) 25%, rgba(0,0,20,0.3)50%)
- border-radius: 25px
- border: |
[[[
if (states['light.esp32_bluetooth_proxy_1_led_gpio2'].state === "on") return '3px solid blue';
else return '3px solid red';
]]]
- color: ivory
name:
- text-transform: null
- color: white
- font-weight: bold
- font-size: 80%
- padding: 15px 0px 0px 0px
label:
- color: white
- justify-self: middle
- font-weight: bold
- padding: 5px 0px 0px 0px
state:
- value: spento
icon: mdi:bluetooth-off
color: red
- value: acceso
icon: mdi:bluetooth
color: blue