Condition if home assistant is offline

Hi guys,
I have esp8266 devices with relays and esphomelib firmware.
In my setup when I press a button switch on the philips hue lights and skip the integrate relay.
I wanted to do this because it’s more beautiful as an effect.
The only problem is that if the home assistant is not active I cannot switch on the lights in the house …
how can I create a condition where, if the esp8266 device does not detect home assistant server and when the button is pressed, the relays are activated or deactivated?

This is my configuration, thanks

esphome:
name: corridoio
platform: ESP8266
board: d1_mini

wifi:
ssid: ‘*******’
password: ‘********’
manual_ip:
static_ip: *********
gateway: *********
subnet: 255.255.255.0
domain: .corridoio.local

Enable logging

logger:

Enable Home Assistant API

api:

ota:

web_server:
port: 80

sensor:

  • platform: wifi_signal
    name: “Cor. WiFi”
    update_interval: 60s

binary_sensor:

  • platform: gpio
    id: corpir
    name: “Corridoio Pir”
    device_class: motion
    pin:
    number: D4
    on_press:
    if:
    condition:
    - switch.is_on: correle
    then:
    - homeassistant.service:
    service: light.turn_on
    data:
    entity_id: light.corridoio_2
    else:
    - switch.turn_on: correle
    - delay: 500ms
    - homeassistant.service:
    service: light.turn_on
    data:
    entity_id: light.corridoio_2

  • platform: template
    name: “Corridoio Pir Time”
    lambda: ‘return id(corpir).state;’
    filters:

    • delayed_off: 30s
      on_release:
    • homeassistant.service:
      service: light.turn_off
      data:
      entity_id: light.corridoio_2
  • platform: gpio
    name: “Pulsante Cor.1”
    pin:
    number: TX
    inverted: True
    on_multi_click:

    • timing:
      • ON for at most 1s
      • OFF for at most 1s
      • ON for at most 1s
      • OFF for at least 0.5s
        then:
      • homeassistant.service:
        service: light.toggle
        data:
        entity_id: light.corridoio_2
      • logger.log: “2Click”
    • timing:
      • ON for 1s to 2s
      • OFF for at least 0.5s
        then:
      • homeassistant.service:
        service: light.turn_off
        data:
        entity_id: light.sala
      • homeassistant.service:
        service: light.turn_off
        data:
        entity_id: light.cucina
      • homeassistant.service:
        service: switch.turn_off
        data:
        entity_id: switch.led_cucina_rele
      • logger.log: “LongPress”
    • timing:
      • ON for at most 1s
      • OFF for at least 0.5s
        then:
        if:
        condition:
        • switch.is_on: salarele
          then:
        • homeassistant.service:
          service: light.toggle
          data:
          entity_id: light.sala
        • logger.log: “Click”
          else:
        • switch.turn_on: salarele
        • homeassistant.service:
          service: light.toggle
          data:
          entity_id: light.sala
        • logger.log: “Click”
  • platform: gpio
    name: “Pulsante Cor.2”
    pin:
    number: RX
    inverted: True
    on_multi_click:

    • timing:
      • ON for at most 1s
      • OFF for at most 1s
      • ON for at most 1s
      • OFF for at least 0.5s
        then:
      • logger.log: “2Click”
      • homeassistant.service:
        service: switch.toggle
        data:
        entity_id: switch.led_cucina_rele
    • timing:
      • ON for 1s to 2s
      • OFF for at least 0.5s
        then:
      • homeassistant.service:
        service: light.turn_on
        data:
        entity_id: light.sala
      • homeassistant.service:
        service: light.turn_on
        data:
        entity_id: light.cucina
      • homeassistant.service:
        service: switch.turn_on
        data:
        entity_id: switch.led_cucina
      • logger.log: “LongPress”
    • timing:
      • ON for at most 1s
      • OFF for at least 0.5s
        then:
      • homeassistant.service:
        service: light.toggle
        data:
        entity_id: light.cucina
      • logger.log: “Click”

switch:

  • platform: gpio
    id: correle
    name: “Cor. rele”
    pin:
    number: D5
    mode: OUTPUT

  • platform: gpio
    id: salarele
    name: “Sala rele”
    pin:
    number: D7
    mode: OUTPUT

I think this is what you’re looking for:

-josh

after a similar option “Home Assistant” yet again crashed during a update

and heaters were stuck on all day long

wanting a option so the esp will Turn off if their is a connection issue

1 Like