Quantcast
Channel: ESPHome - Home Assistant Community
Viewing all articles
Browse latest Browse all 1486

[SOLVED] ESPHome + Sonoff Mini

$
0
0

Hi all,

So, I have a wall switch (Simple rocker type) with a Sonof Mini behind it. This wall switch controls the lounge lights. I recently installed two lamps in my lounge; both connected to two son off basics.

I wanted to have an “automation” where if I toggle the wall switch (turn it on and off) within 350ms - the lamps turn on and the main lounge lights stay off.

I managed to do this by doing the following:

  1. Remove the config from ESPHome
  2. Setup a flow in NodRed (Which is connected to HA)

The flow in NodRed does this:

Switch stage changed -> did it do on and off within 350ms? - if so - turn lamps on - else toggle lounge lights

This got me the desired outcome. Then I got thinking; what happens if HA died? My wall switch would do nothing. Because I removed the config from ESPHome to turn on the relay / lights

So, this is my question

Is it possible to configure ESPHome to do the following:

“If switch status changes (off -> on -> off) within < 350mm -. ignore this.” Else turn on or off the light depending on the state of switch.

I have tried all sorts of things with if-conditions and such. But the lights “flicker” for a brief period when I toggle the switch.

This is my latest attempt:


binary_sensor:
  - platform: gpio
    pin: GPIO00
    id: reset
    internal: true
    # on_press:
    #   - light.toggle: 
    #       id: lounge_lights

  - platform: gpio
    name: 'Lounge lights switch'
    pin: GPIO04
    id: switch_1
    on_press:
        - if:
           condition:
            for:
              time: 5s #added long delays for testing
              condition:
                - binary_sensor.is_on: switch_1
           then:
              - delay: 5s
        - if:
           condition:
               - light.is_off: lounge_lights
           then:
              - light.turn_on: lounge_lights
    on_release:
        - if:
           condition:
            for:
              time: 5s
              condition:
                - binary_sensor.is_off: switch_1
           then:
              - delay: 5s
        - if:
           condition:
               - light.is_on: lounge_lights
           then:
              - light.turn_off: lounge_lights

5 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 1486

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>