Sonoff SwitchMan M5 3C 3 Gang switch with ESPHome

I somehow prefer to code actions directly in ESPHOME setup rather than firing events to HA and then reacting over there, i.e.

- timing: #short
          - ON for at most 1s
          - OFF for at least 0.05s
        then:
          - if:
              condition: 
                api.connected:
              then:
                - homeassistant.service:
                    service: light.toggle
                    data:
                      entity_id: light.table_lamp
              else:
              - http_request.post: "http://192.168.10.77/light/table_lamp/toggle"

btw,the condition is to go directly to Esphome device if HA is unavailable (fallback option, HA way reacts way faster)

5 Likes