# ESPHome Firmware for # Sonoff Switchman M5 3-Gang US # Copyright (c) 2024 Mario Di Vece # License: [MIT](https://opensource.org/license/mit/) # Decription: # Aims to provide a feature-rich, production-ready firmware for this elegant device # - Provides Diagnostic data plus, status LED indicator when not connected to Home Assistant API # - Relays may be configured individually on the UI to work in decoupled mode. # LEDs are physically connected to the relays, and they can't be individually controlled :( # - Exposes gestures via events: # esphome.on_gesture { button: (A|B|C), gesture: (click|double_click|button_hold) } # - Off-state (Background Brightness) of the LEDs is configurable via the UI # # For the below example, you need to keep the following entries in your secrets.yaml file: # - wifi_ssid: "" # - wifi_password: "" # - ota_password: "" # - api_key: "<32-byte-base-64-secret>" # # Example file (lab-office-wasw-003.yaml) # # substitutions: # device_site: "lab" # device_location_code: "office" # device_location_name: "Office" # device_type_code: "wasw" # device_type_name: "Wall Switch" # device_number: "003" # device_ip: "192.168.1.31" # # packages: # base_package: # url: https://github.com/mariodivece/esphometemplates/ # ref: main # file: sonoff-m5-3g-us.yaml # refresh: 0d # substitutions: # User-required substitutions device_site: "home" device_location_code: "bedroom01" device_location_name: "Bedroom 1" device_type_code: "wasw" device_type_name: "Wall Switch" device_number: "044" device_ip: "0.0.0.0" # Project Substitutions (not intended for user substitution) device_model: "Switchman M5 (3-Gang)" device_make: "Sonoff" package_version: "2024.2.13" package_url: "github://mariodivece/esphometemplates/sonoff-m5-3g-us.yaml@main" # Relay Configurations relay_a_gpio: GPIO23 relay_b_gpio: GPIO19 relay_c_gpio: GPIO22 # Button Configurations button_a_gpio: GPIO04 button_b_gpio: GPIO00 button_c_gpio: GPIO15 # Allow importing this package dashboard_import: package_import_url: ${package_url} import_full_config: false # Import packages packages: standard_package: url: https://github.com/mariodivece/esphometemplates/ ref: main refresh: 0d files: - standard/project.yaml - standard/diagnostics.yaml - standard/wifi.yaml - standard/internaltemp.yaml sonoffm5_package: url: https://github.com/mariodivece/esphometemplates/ ref: main refresh: 0d files: - sonoff-m5/board.yaml - sonoff-m5/timings.yaml - sonoff-m5/status-led.yaml - sonoff-m5/backlight.yaml - sonoff-m5/mode-button-a.yaml - sonoff-m5/mode-button-b.yaml - sonoff-m5/mode-button-c.yaml - sonoff-m5/relay-a.yaml - sonoff-m5/relay-b.yaml - sonoff-m5/relay-c.yaml - sonoff-m5/button-a.yaml - sonoff-m5/button-b.yaml - sonoff-m5/button-c.yaml binary_sensor: # Buttn A - id: !extend button_a on_press: # Latching - if: condition: - lambda: 'return id(mode_a).active_index() == 0;' then: - switch.toggle: relay_a # Momentary - if: condition: - lambda: 'return id(mode_a).active_index() == 1;' then: - switch.turn_on: relay_a # Pulse - if: condition: - lambda: 'return id(mode_a).active_index() == 2;' then: - switch.turn_on: relay_a - delay: ${timing_pulse} - switch.turn_off: relay_a on_release: # Momentary - if: condition: - lambda: 'return id(mode_a).active_index() == 1;' then: - switch.turn_off: relay_a # Button B - id: !extend button_b on_press: # Latching - if: condition: - lambda: 'return id(mode_b).active_index() == 0;' then: - switch.toggle: relay_b # Momentary - if: condition: - lambda: 'return id(mode_b).active_index() == 1;' then: - switch.turn_on: relay_b # Pulse - if: condition: - lambda: 'return id(mode_b).active_index() == 2;' then: - switch.turn_on: relay_b - delay: ${timing_pulse} - switch.turn_off: relay_b on_release: # Momentary - if: condition: - lambda: 'return id(mode_b).active_index() == 1;' then: - switch.turn_off: relay_b # Button C - id: !extend button_c on_press: # Latching - if: condition: - lambda: 'return id(mode_c).active_index() == 0;' then: - switch.toggle: relay_c # Momentary - if: condition: - lambda: 'return id(mode_c).active_index() == 1;' then: - switch.turn_on: relay_c # Pulse - if: condition: - lambda: 'return id(mode_c).active_index() == 2;' then: - switch.turn_on: relay_c - delay: ${timing_pulse} - switch.turn_off: relay_c on_release: # Momentary - if: condition: - lambda: 'return id(mode_c).active_index() == 1;' then: - switch.turn_off: relay_c