Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 106113

Conditional formatting for a simple switch

$
0
0

Hello, guys; I am stuck trying to figure this one out. I’ve been down, through and back around the rabbit hole.

I have an ESP32, which I am trying to use to monitor and control my swimming pool.

I have the Temperature monitoring working fine using a DS18B20 Temperature Sensor.

A float switch connected to GPIO25 will tell me when the pool level is correct.

A switch triggers a relay on GPIO14 to open and close a water solenoid, which will fill the pool through a water feature.

I use a TP-Link Tapo plug-in GPO monitor / switch to control the timing of the pool filter pump. switch.pool_pump

I have the temperature sensor working.

I can close the “Float Switch” on GPIO25, which in turn triggers the “water solenoid” on GPIO14

I am placing the Float Switch and Temperature sensor inside the pool skimmer box so it is out of site. To achieve an accurate water level, the float switch should only monitor the water level once the pool_pump switch is off, and has been off for a minute or so. And all so turn off the water solenoid when the pool_pump starts. (This is because the pool pump draws so much water from the skimmer box that the level would not be accurate) I want an indication on the Dashboard whether the pool is filling or not to allow me to pick up faults, etc.

Can I achieve this with code? I have tried adding to the lambda, but I got pretty lost in there :slight_smile: . Would automation be a better option?

Thanks for your help in advance.
Bruce

captive_portal:
# Configuration for Temp sensor
# one-wire BUS
one_wire:
  - platform: gpio
    pin: GPIO4

sensor:
  - platform: dallas_temp
    name: "pool-temperature"
    #class: temperature
    id: Temp
    update_interval: 10s
    unit_of_measurement: '°C'
  
# water solenoid for pool filling
switch:
  - platform: gpio
    pin: 
      number: GPIO14
      inverted: True
      mode:
        output: True
        pullup: False
    name: "Pool Filling"
    id: pool_filling_solenoid
    
    
#   Float Switch / Sensor to trigger filling
binary_sensor: 
  - platform: gpio
    pin:
      inverted: true
      number: GPIO25
      mode: 
        input: true
        pullup: true
    #device_class: moisture
    name: "float-switch"
    id: float_switch

    on_state:
      then:
        - lambda: |-
            if (id(float_switch).state) {
              id(pool_filling_solenoid).turn_on();
            } else {
              id(pool_filling_solenoid).turn_off();
            }
    filters:
      # Small filter, to debounce the switch
      - delayed_on: 25ms
      - delayed_off: 25ms

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 106113

Trending Articles



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