Arm switch for script

I control my fireplace through the main UI and want to make it a two step process to prevent accidental clicks. So something where I toggle an input boolean that automatically disables after 5 seconds (I got that part working). Only while the input boolean is on can you then press the buttons that run the scripts that send the MQTT commands to turn on/off the fireplace.
Prettiest would be that the UI elements themselves become gray until you toggle the input Boolean.
If that is not possible I need to embed a test in the scripts to test the condition of the input boolean and not execute if it is not in on position.

haard_uit:
  alias: Haard uit
  icon: mdi:fire-extinguisher
  sequence:
  - service: mqtt.publish
    data_template:
      payload: '{"value":2043326,"protocol":5,"length":22,"delay":367}'
      topic: home/OpenMQTTGateway_ESP8266_RF/commands/MQTTto433
      retain: true
  - delay: 00:00:01
  - service: mqtt.publish
    data_template:
      payload: '{"value":2043326,"protocol":5,"length":22,"delay":367}'
      topic: home/OpenMQTTGateway_ESP8266_RF/commands/MQTTto433
      retain: true
  - delay: 00:00:01
  - service: mqtt.publish
    data_template:
      payload: '{"value":2043326,"protocol":5,"length":22,"delay":367}'
      topic: home/OpenMQTTGateway_ESP8266_RF/commands/MQTTto433
      retain: true
  - delay: 00:00:01
  - service: mqtt.publish
    data_template:
      payload: '{"value":2043326,"protocol":5,"length":22,"delay":367}'
      topic: home/OpenMQTTGateway_ESP8266_RF/commands/MQTTto433
      retain: true
haard_max:
  alias: Haard maximaal
  icon: mdi:fireplace
  sequence:
  - service: mqtt.publish
    data_template:
      payload: '{"value":2043316,"protocol":26,"length":22,"delay":367}'
      topic: home/OpenMQTTGateway_ESP8266_RF/commands/MQTTto433
      retain: true
haard_min:
  alias: Haard minimaal
  icon: mdi:fireplace-off
  sequence:
  - service: mqtt.publish
    data_template:
      payload: '{"value":2043316,"protocol":5,"length":22,"delay":367}'
      topic: home/OpenMQTTGateway_ESP8266_RF/commands/MQTTto433
      retain: true

I don’t know how your frontend looks like and how you show this commands, however, I think the “lock” attribute of the custom-button-card should do what you want. You then need to press the button first to unlock it and press the button again to execute the service and the button should lock itself automatically a few seconds after it was unlocked.

1 Like

Thanks, that seems to work. I found the restriction-card in HACS and decided to use that because it is simpler.