Lokale Automatisierung in ESPHome nur ausführen, wenn MQTT nicht erreichbar ist

Nanoleaf Shapes Hexagon Starter Kit, 9 Smarten LED Panels RGBW - Modulare WLAN 16 Mio. Farben Wandleuchte Innen, Musik & Bildschirm Sync, Funktioniert mit Alexa Google Apple, für Deko & Gaming
Nanoleaf Shapes Hexagon Starter Kit, 9 Smarten LED Panels RGBW - Modulare WLAN 16 Mio. Farben Wandleuchte Innen, Musik & Bildschirm Sync, Funktioniert mit Alexa Google Apple, für Deko & Gaming
Unverb. Preisempf.: 199,99 € (22,22 € / stück)
144,99 € (16,11 € / stück)
Sie sparen 55,00 € (28%)

Arek Swistak war so nett ein Beispiel für eine ESPHome Automatisierung mit uns zu teilen, die nur ausgeführt wird, wenn der hinterlegte MQTT-Broker nicht erreichbar ist.

Danke dafür!

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO5
    name: "Schalter"
    on_state:
      if:
        condition:
          mqtt.connected:
        then:
         - logger.log: Mqtt is connected!
        else:
         - light.toggle: schalter_id
    internal: true

output:
  - platform: gpio
    pin: GPIO4
    id: lampe

mqtt:
  broker: broker ip
  username: "user"
  password: "passwordmqtt"