Sonoff mini switch

Hi every one.

I want to use a sonoff mini with esphome on a regulare push switch to controll a light group i have in home assistant.

I want it to be so if i “click” the switch i toggle the ligth group on and off, but if i hold the switch it “dims” to max and if i hold it again it “dims” to min.

Is this posible only using esphome scripting??

In a word, yes.

Awsome.

Any suggestion how??

I have read in this thread https://community.home-assistant.io/t/push-button-dimmer-how/112361/23

But i can’t figure out how to do it in terms of controlling a light group.

That solution will not work for you as it is controlling devices directly wired to the ESP GPIOs. ESPHome does not have light groups. And there is no way to import a home assistant light into ESPHome.

You would have to write a similar ESP configuration that publishes a brightness sensor to Home Assistant. Then use an automation in home assistant to monitor this sensor for changes and addjst your light as required.

Don’t have dimmer setup on long press yet but

This controls my Hass light group


      
binary_sensor:
  - platform: gpio
    pin:
      number: $button_gpio
    name: $project Wall Switch
    id: button
    filters:
      - delayed_on: 100ms
      - delayed_off: 100ms
      - delayed_on_off: 100ms        
    on_release:
      - script.execute: hass_light_toggle      

  
script:
  - id: hass_light_toggle
    then:
      if:
        condition:
          api.connected:
        then:
          - if:
              condition:
                switch.is_off: relay
              then:
                # Turn the relay back on and turn on the light.
                - switch.turn_on: relay

                - homeassistant.service:
                    service: light.turn_on
                    data:
                      entity_id: $hass_light_1
                      transition: "3"  

              else:
                # Have Home Assistant toggle the light.
                - homeassistant.service:
                    service: light.toggle
                    data:
                      entity_id: $hass_light_1
                      transition: "3" 

        else:
          # When HA is unavailable, toggle the relay.
          - switch.toggle: relay

Relay is always on. But will toggle if not connected to home assistant. Which will turn lights on off lights that are connected to relay as dumb lights. Otherwise script will control smart lights via home assistant