qd4-vorplatz-garten - Show valve switches in Home Assistant

To allow direct switching of the valves we activated their name attributes.

To allow direct switching of the valves we activated their name attributes. This is the resulting config:

esphome:
  name: qd4-vorplatz-garten
  friendly_name: qd4-vorplatz-garten
  comment: QuinLED Dig Quad with I2C extensions for additional GPIO ports for irrigation valves and analog LED channels
  # qd4 = quinled-dig-quad

esp32:
  board: mhetesp32minikit
  framework:
    type: esp-idf

ethernet:
  type: LAN8720
  mdc_pin: GPIO23
  mdio_pin: GPIO18
  clk: 
    pin: GPIO17
    mode: CLK_OUT
  phy_addr: 0
  power_pin: GPIO5

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "KzgSjwd43SzHl2mXEg/UC8roOMkJl3odbbLlNvKFmu8="

ota:
  - platform: esphome
    password: "a244b4e02d0d2f38c6ac5422e81ba4a8"

time:
- platform: homeassistant
  id: homeassistant_time
  timezone: "Europe/Berlin"

one_wire:
  - platform: gpio
    pin: 13

i2c:
  sda: GPIO32 # Q4 - yellow
  scl: GPIO2 # Q3 - green
  scan: true

pcf8574:
  - id: 'pcf8574_irrigation'
    address: 0x20
    pcf8575: false

sensor:
  - platform: dallas_temp
    address: 0x450621b4251edd28
    name: "Strg Bel Temperatur"
    id: board_temp_sensor
    update_interval: 10s
    accuracy_decimals: 1

  - platform: bme280_i2c
    address: 0x76
    temperature:
      name: "Strg Bew Temperatur"
      id: bme280_temperature
    pressure:
      name: "Strg Bew Luftdruck"
    humidity:
      name: "Strg Bew Luftfeuchtigkeit"
      id: bme280_humidity

  - platform: template
    name: "Taupunkt"
    id: tpl_dewpoint
    lambda: |-
      const float a = 17.27;
      const float b = 237.7;
      float temp = id(bme280_temperature).state;
      float hum = id(bme280_humidity).state / 100.0;
      float alpha = logf(hum) + (a * temp) / (b + temp);
      return (b * alpha) / (a - alpha);
    unit_of_measurement: "°C"
    icon: "mdi:thermometer-alert"
    update_interval: 10s

  - platform: uptime
    type: timestamp
    name: Uptime

switch:
  # Lighting
  - platform: gpio
    name: "Trafo Beleuchtung"
    id: switch_transformer_lighting
    icon: "mdi:power-socket"
    pin: 
      number: GPIO15
      inverted: false
      mode:        
        output: true

  # Irrigation valves power
  - platform: gpio
    name: "Trafo Bewässerung"
    id: switch_transformer_irrigation
    icon: "mdi:power-socket"
    pin:
      pcf8574: pcf8574_irrigation
      number: 0
      inverted: true
      mode:        
        output: true

  # Valve 1/1 - Outlets (Zapfstellen)
  - platform: gpio
    id: switch_irrigation_outlets
    name: "Ventil Zapfstellen"
    pin:
      pcf8574: pcf8574_irrigation
      number: 1
      inverted: true
      mode:
        output: true

  # Valve 1/2 - Roses (Beet Stützmauer und Beet Eingang privat)
  - platform: gpio
    id: switch_irrigation_roses
    name: "Ventil Rosen und Stützmauer"
    pin:
      pcf8574: pcf8574_irrigation
      number: 2
      inverted: true
      mode:
        output: true

  # Valve 1/3 - Trees and hedge (Bäume Vorplatz und Hecke Haupteingang)
  - platform: gpio
    id: switch_irrigation_trees
    name: "Ventil Bäume und Hecke"
    pin:
      pcf8574: pcf8574_irrigation
      number: 3
      inverted: true
      mode:
        output: true

  # Valve 1/4 - Pond (Nachspeisung Teich)
  - platform: gpio
    id: switch_irrigation_pond
    name: "Ventil Nachspeisung Teich"
    pin:
      pcf8574: pcf8574_irrigation
      number: 4
      inverted: true
      mode:
        output: true

sprinkler:
  - id: sprinkler_parking_distributor
    main_switch: "Vorplatz Bewässerung"
    auto_advance_switch: "Vorplatz Bewässerung Automatik"
    reverse_switch: "Vorplatz Bewässerung Umkehrung"
    valve_overlap: 5s
    valves:
      - valve_switch: "Bew. Bäume und Hecke"
        enable_switch: "Bew. Bäume und Hecke aktivieren"
        pump_switch_id: switch_transformer_irrigation
        run_duration: 900s
        valve_switch_id: switch_irrigation_trees
      - valve_switch: "Bew. Rosen und Stützmauer"
        enable_switch: "Bew. Rosen und Stützmauer aktivieren"
        pump_switch_id: switch_transformer_irrigation
        run_duration: 900s
        valve_switch_id: switch_irrigation_roses
      - valve_switch: "Bew. Zapfstellen"
        pump_switch_id: switch_transformer_irrigation
        run_duration: 6s
        valve_switch_id: switch_irrigation_outlets
      - valve_switch: "Bew. Teich"
        pump_switch_id: switch_transformer_irrigation
        run_duration: 6s
        valve_switch_id: switch_irrigation_pond

light:
  - platform: esp32_rmt_led_strip
    chipset: SK6812 #ws2812
    pin: GPIO16
    # Channel 1
    # 4 lamps with 45 LEDs
    num_leds: 180
    is_wrgb: false
    rgb_order: GRB
    id: led_channel_1
    internal: true

  - platform: partition
    name: "Moonlight 1"
    id: led_moonlight_1_1
    # Big Moonlight with 45 LEDs
    segments: 
      - id: led_channel_1
        from: 0
        to: 44
    effects:
      - addressable_rainbow:
      - addressable_rainbow:
          name: Rainbow Effect With Custom Values
          speed: 10
          width: 512
      - addressable_rainbow:
          name: Rainbow mega fast
          speed: 20
          width: 150
      - addressable_color_wipe:
      - addressable_scan:
      - addressable_twinkle:
      - addressable_fireworks:
    on_turn_on:
      - switch.turn_on: switch_transformer_lighting
    on_turn_off:
      - if:
          condition:
            - light.is_off: led_moonlight_1_2
            - light.is_off: led_moonlight_1_3
            - light.is_off: led_moonlight_1_4
          then:
            - switch.turn_off: switch_transformer_lighting

  - platform: partition
    name: "Moonlight 2"
    id: led_moonlight_1_2
    # Medium Moonlight with 45 LEDs
    segments: 
      - id: led_channel_1
        from: 45
        to: 89
    effects:
      - addressable_rainbow:
      - addressable_rainbow:
          name: Rainbow Effect With Custom Values
          speed: 10
          width: 512
      - addressable_rainbow:
          name: Rainbow mega fast
          speed: 20
          width: 150
      - addressable_color_wipe:
      - addressable_scan:
      - addressable_twinkle:
      - addressable_fireworks:
    on_turn_on:
      - switch.turn_on: switch_transformer_lighting
    on_turn_off: 
      - if:
          condition:
            - light.is_off: led_moonlight_1_1
            - light.is_off: led_moonlight_1_3
            - light.is_off: led_moonlight_1_4
          then:
            - switch.turn_off: switch_transformer_lighting

  - platform: partition
    name: "Moonlight 3"
    id: led_moonlight_1_3
    # Medium Moonlight with 45 LEDs
    segments: 
      - id: led_channel_1
        from: 90
        to: 134
    effects:
      - addressable_rainbow:
      - addressable_rainbow:
          name: Rainbow Effect With Custom Values
          speed: 10
          width: 512
      - addressable_rainbow:
          name: Rainbow mega fast
          speed: 20
          width: 150
      - addressable_color_wipe:
      - addressable_scan:
      - addressable_twinkle:
      - addressable_fireworks:
    on_turn_on:
      - switch.turn_on: switch_transformer_lighting
    on_turn_off: 
      - if:
          condition:
            - light.is_off: led_moonlight_1_1
            - light.is_off: led_moonlight_1_2
            - light.is_off: led_moonlight_1_4
          then:
            - switch.turn_off: switch_transformer_lighting

  - platform: partition
    name: "Moonlight 4"
    id: led_moonlight_1_4
    # Medium Moonlight with 45 LEDs
    segments: 
      - id: led_channel_1
        from: 135
        to: 179
    effects:
      - addressable_rainbow:
      - addressable_rainbow:
          name: Rainbow Effect With Custom Values
          speed: 10
          width: 512
      - addressable_rainbow:
          name: Rainbow mega fast
          speed: 20
          width: 150
      - addressable_color_wipe:
      - addressable_scan:
      - addressable_twinkle:
      - addressable_fireworks:
    on_turn_on:
      - switch.turn_on: switch_transformer_lighting
    on_turn_off: 
      - if:
          condition:
            - light.is_off: led_moonlight_1_1
            - light.is_off: led_moonlight_1_2
            - light.is_off: led_moonlight_1_3
          then:
            - switch.turn_off: switch_transformer_lighting

#  - platform: esp32_rmt_led_strip
#    chipset: SK6812 #ws2812
#    pin: GPIO3
#    num_leds: 0
#    is_wrgb: false
#    rgb_order: GRB
#    name: "LED Kanal 2"
#    id: led_channel_2
#    effects:
#      - addressable_rainbow:
#      - addressable_rainbow:
#          name: Rainbow Effect With Custom Values
#          speed: 10
#          width: 512
#      - addressable_rainbow:
#          name: Rainbow mega fast
#          speed: 20
#          width: 150
#      - addressable_color_wipe:
#      - addressable_scan:
#      - addressable_twinkle:
#      - addressable_fireworks:
#    on_turn_on:
#      - switch.turn_on: switch_transformer_lighting
#    on_turn_off: 
#      - if:
#          condition:
#            - light.is_off: led_channel_1
#            - light.is_off: led_channel_3
#          then:
#            - switch.turn_off: switch_transformer_lighting

#  - platform: esp32_rmt_led_strip
#    chipset: SK6812 #ws2812
#    pin: GPIO1
#    num_leds: 0
#    is_wrgb: false
#    rgb_order: GRB
#    name: "LED Kanal 3"
#    id: led_channel_3
#    effects:
#      - addressable_rainbow:
#      - addressable_rainbow:
#          name: Rainbow Effect With Custom Values
#          speed: 10
#          width: 512
#      - addressable_rainbow:
#          name: Rainbow mega fast
#          speed: 20
#          width: 150
#      - addressable_color_wipe:
#      - addressable_scan:
#      - addressable_twinkle:
#      - addressable_fireworks:
#    on_turn_on:
#      - switch.turn_on: switch_transformer_lighting
#    on_turn_off: 
#      - if:
#          condition:
#            - light.is_off: led_channel_2
#            - light.is_off: led_channel_3
#          then:
#            - switch.turn_off: switch_transformer_lighting

Done 😄