tIGGER
(Johanna Caster)
March 14, 2022, 11:45am
1
Good companions. I would like to prevent a selector from being pressed twice or more for a given time. This card activates and mounts an external hard disk, I want to avoid any anomaly when turning the hard disk on and off abruptly or avoid pressing twice in a row by mistake.
My card is the conditional type and when the switch is pressed the card disappears, but it takes two or three seconds. I want it to disappear immediately after the click (2 seconds). It’s possible?
type: conditional
conditions:
- entity: sensor.sensor_log
state: SYSTEM CONSOLE
card:
type: entities
title: null
entities:
- entity: input_boolean.mount_dismount
name: DISK_1
style: |
:host {
--paper-item-icon-color:
{% if states('input_boolean.mount_dismount') == 'on' %}
red
{% elif states('input_boolean.mount_dismount') == 'off' %}
black
{% else %}
var(--state-icon-color)
{% endif %}
;
}
petro
(Petro)
March 14, 2022, 11:50am
2
This is just a input_boolean. What does your automation look like?
tIGGER
(Johanna Caster)
March 14, 2022, 12:14pm
3
Sorry, here I leave the whole system:
automations:
alias: Mount_14tb
description: ''
trigger:
- platform: state
to: 'on'
entity_id: input_boolean.mount_dismount
from: 'off'
condition: []
action:
- type: turn_on
device_id: e8684b52b518f833f4fdeb4a78564e81
entity_id: switch.disk_14tb
domain: switch
- service: shell_command.mount_disck
data: {}
mode: single
-----
alias: Dismount_14tb
description: ''
trigger:
- platform: state
entity_id: input_boolean.mount_dismount
to: 'off'
from: 'on'
condition: []
action:
- service: shell_command.dismount_disck
data: {}
- wait_for_trigger:
- platform: state
entity_id: sensor.sensor_log
to: DISK_14tb Dismount
continue_on_timeout: false
- type: turn_off
device_id: e8684b52b518f833f4fdeb4a78564e81
entity_id: switch.disk_14tb
domain: switch
mode: single
shell_commands:
mount_disck: ssh -i /config/.ssh/id_rsa -o 'StrictHostKeyChecking=no' [email protected] 'sudo sh /_comandos/montar.sh /dev/disk/by-uuid/a50e9ebe-e44c-4114-b969-32b3835c6d1d DISK_14tb'
dismount_disck: ssh -i /config/.ssh/id_rsa -o 'StrictHostKeyChecking=no' [email protected] 'sudo sh /_comandos/desmontar.sh /dev/disk/by-uuid/a50e9ebe-e44c-4114-b969-32b3835c6d1d DISK_14tb'
card:
type: conditional
conditions:
- entity: sensor.sensor_log
state: SYSTEM CONSOLE
card:
type: entities
title: null
entities:
- entity: input_boolean.mount_dismount
name: DISK_1
style: |
:host {
--paper-item-icon-color:
{% if states('input_boolean.mount_dismount') == 'on' %}
red
{% elif states('input_boolean.mount_dismount') == 'off' %}
black
{% else %}
var(--state-icon-color)
{% endif %}
;
}
Have you considered custom-cards /button-card ?
You have options such as a confirmation prompt as well as a long-press of the button. Suspect either would be suitable here.