Hi all.
Just playing around with some code to carry out an automation. Normally I use node-red but I am using a esp32 and need it to run even if HA is offline.
I have the first part working. When the temp of the sensor gets above 30 it turns on the pump. Well I had it working but since I changed it to a script I havent tested it. In the script I turn a global variable to true then turn on an output. 30 seconds later I turn off that variable.
So I have an ADC measuring current. The pump it turns on and off when first turned on draws say 2 amps untill it builds pressure then it draws 3 amps. It takes around 20 seconds to do this.
So I want check the current every 10 seconds and if the current is below say 2.8 turn off the pump. BUT during the time the global variable is set to true, simply ignore it. So my second script is where I am lost. Not sure how to do the if part if someone could offer some help
esphome:
name: bathroomgrey
platform: ESP32
board: esp-wrover-kit
globals:
- id: pump_current_ignore
type: bool
restore_value: no
initial_value: "false"
esphome:
name: bathroomgrey
platform: ESP32
board: esp-wrover-kit
globals:
- id: pump_current_ignore
type: bool
restore_value: no
initial_value: "false"
wifi:
ssid: "ssid"
password: "pass"
dallas:
- pin: GPIO23
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
script:
- id: start_pump
then:
- globals.set:
id: pump_current_ignore
value: 'true'
- switch.turn_on: BGP
- delay: 30s
- globals.set:
id: pump_current_ignore
value: 'false'
- id: stop_pump
then:
- if:
condition:
sensor:
# - platform: uptime
# name: Uptime Sensor
- platform: dallas
address: 0xA0011454FEF2AA28
name: "Bath Shower Sensor"
on_value_range:
- above: 30.0
then:
- script.execute: start_pump
- platform: adc
pin: A0
name: "Bath Current"
update_interval: 10s
filters:
- multiply: 10
on_value_range:
- below: 3.0
then:
- script.execute: stop_pump
switch:
- platform: gpio
pin: 2
name: "Bath GW Pump"
id: BGP
icon: "mdi:fountain"