I have the below now, but still fails… anyone…?
### RETIC CONTROLLER CODE FOR ESP8266 ###
# Pin assignments
# D0 Try not to use
# D1 In / Out
# D2 In / Out
# D3 Out
# D4 Out
# D5 In / Out
# D6 In / Out
# D7 In / Out
# D8 In / Out
# D9 In / Out ?? (tied to USB, cant use with debug)
# D10 In /Out ?? (tied to USB, cant use with debug)
# SD3 In / Out
esphome:
name: reticulation_controller
platform: ESP8266
board: nodemcuv2
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
manual_ip:
static_ip: 192.168.0.61 # to be confirmed on IP Address Table spreadsheet
gateway: 192.168.0.1
subnet: 255.255.255.0
mqtt:
broker: '192.168.0.13'
username: !secret mqtt_username
password: !secret mqtt_password
discovery: False
api:
# Enable logging
logger:
ota:
password: !secret ota_password
i2c:
sda: D0
scl: D1
display:
- platform: lcd_pcf8574
dimensions: 18x2
address: 0x3F
font:
- file: 'alpha_romanie_g98.ttf'
id: font1
size: 8
time:
- platform: homeassistant
id: homeassistant_time
sensor:
- platform: mqtt_subscribe
name: "Program 1 Start Time 1"
id: program1start1
topic: retic/program1/start1
- platform: mqtt_subscribe
name: "Program 1 Start Time 2"
id: program1start2
topic: retic/program1/start2
- platform: mqtt_subscribe
name: "Program 2 Start Time 1"
id: program2start1
topic: retic/program2/start1
- platform: mqtt_subscribe
name: "Program 2 Start Time 2"
id: program2start2
topic: retic/program2/start2
- platform: mqtt_subscribe
name: "Program 3 Start Time 1"
id: program3start1
topic: retic/program3/start1
- platform: mqtt_subscribe
name: "Program 3 Start Time 2"
id: program3start2
topic: retic/program3/start2
- platform: mqtt_subscribe
name: "Program 1 Station 1 Run Time"
id: program1station1runtime
topic: retic/program1/station1runtime
- platform: mqtt_subscribe
name: "Program 1 Station 2 Run Time"
id: program1station2runtime
topic: retic/program1/station2runtime
- platform: mqtt_subscribe
name: "Program 1 Station 3 Run Time"
id: program1station3runtime
topic: retic/program1/station3runtime
- platform: mqtt_subscribe
name: "Program 1 Station 4 Run Time"
id: program1station4runtime
topic: retic/program1/station4runtime
- platform: mqtt_subscribe
name: "Program 2 Station 1 Run Time"
id: program2station1runtime
topic: retic/program2/station1runtime
- platform: mqtt_subscribe
name: "Program 2 Station 2 Run Time"
id: program2station2runtime
topic: retic/program2/station2runtime
- platform: mqtt_subscribe
name: "Program 2 Station 3 Run Time"
id: program2station3runtime
topic: retic/program2/station3runtime
- platform: mqtt_subscribe
name: "Program 2 Station 4 Run Time"
id: program2station4runtime
topic: retic/program2/station4runtime
- platform: mqtt_subscribe
name: "Program 3 Station 1 Run Time"
id: program3station1runtime
topic: retic/program3/station1runtime
- platform: mqtt_subscribe
name: "Program 3 Station 2 Run Time"
id: program3station2runtime
topic: retic/program3/station2runtime
- platform: mqtt_subscribe
name: "Program 3 Station 3 Run Time"
id: program3station3runtime
topic: retic/program3/station3runtime
- platform: mqtt_subscribe
name: "Program 3 Station 4 Run Time"
id: program3station4runtime
topic: retic/program3/station4runtime
- platform: mqtt_subscribe
name: "Program 1 Watering Day"
id: program1wateringday
topic: retic/program1/wateringday
- platform: mqtt_subscribe
name: "Program 2 Watering Day"
id: program2wateringday
topic: retic/program2/wateringday
- platform: mqtt_subscribe
name: "Program 3 Watering Day"
id: program3wateringday
topic: retic/program3/wateringday
binary_sensor:
- platform: gpio
name: "Retic Bore Run"
pin:
number: D6
mode: INPUT_PULLUP
filters:
- delayed_on: 10ms
- platform: gpio
name: "Retic Bore Stop"
pin:
number: D7
mode: INPUT_PULLUP
filters:
- delayed_on: 10ms
switch:
- platform: gpio
name: "Retic Station 1 Valve"
id: v1
icon: mdi:water-pump
pin:
number: D2
inverted: true
- platform: gpio
name: "Retic Station 2 Valve"
id: v2
icon: mdi:water-pump
pin:
number: D3
inverted: true
- platform: gpio
name: "Retic Station 3 Valve"
id: v3
icon: mdi:water-pump
pin:
number: D4
inverted: true
- platform: gpio
name: "Retic Station 4 Valve"
id: v4
icon: mdi:water-pump
pin:
number: D5
inverted: true
- platform: gpio
name: "Retic Bore Pump Run"
id: p1
icon: mdi:water-pump
pin:
number: D8
inverted: true
interval:
- interval: 1min
then:
- if:
condition:
- lambda: 'return id(program1wateringday).state == true;'
then:
- if:
condition:
or:
# - lambda: 'return id(homeassistant_time).now() == id(program1start1);'
# - lambda: 'return id(homeassistant_time).now() == id(program1start2);'
- lambda: 'return id(homeassistant_time).now().minute == id(program1start1).minute && id(homeassistant_time).hour == id(program1start1).hour;'
- lambda: 'return id(homeassistant_time).now().minute == id(program1start2).minute && id(homeassistant_time).hour == id(program1start2).hour;'
# - lambda: 'return strftime(0, 0, id(font1), "%H:%M:%S", id(homeassistant_time).now()) == id(program1start1).state;'
# - lambda: 'return strftime(0, 0, id(font1), "%H:%M:%S", id(homeassistant_time).now()) == id(program1start2).state;'
then:
- script.execute: retic_program1_run
- interval: 1min
then:
- if:
condition:
- lambda: 'return id(program2wateringday).state == true;'
then:
- if:
condition:
or:
# - lambda: 'return id(homeassistant_time).now() == id(program2start1);'
# - lambda: 'return id(homeassistant_time).now() == id(program2start2);'
- lambda: 'return id(homeassistant_time).now().minute == id(program2start1).minute && id(homeassistant_time).hour == id(program2start1).hour;'
- lambda: 'return id(homeassistant_time).now().minute == id(program2start2).minute && id(homeassistant_time).hour == id(program2start2).hour;'
# - lambda: 'return strftime(0, 0, id(font1), "%H:%M:%S", id(homeassistant_time).now()) == id(program2start1).state;'
# - lambda: 'return strftime(0, 0, id(font1), "%H:%M:%S", id(homeassistant_time).now()) == id(program2start2).state;'
then:
- script.execute: retic_program2_run
- interval: 1min
then:
- if:
condition:
- lambda: 'return id(program3wateringday).state == true;'
then:
- if:
condition:
or:
# - lambda: 'return id(homeassistant_time).now() == id(program3start1);'
# - lambda: 'return id(homeassistant_time).now() == id(program3start2);'
- lambda: 'return id(homeassistant_time).now().minute == id(program3start1).minute && id(homeassistant_time).hour == id(program3start1).hour;'
- lambda: 'return id(homeassistant_time).now().minute == id(program3start2).minute && id(homeassistant_time).hour == id(program3start2).hour;'
# - lambda: 'return strftime(0, 0, id(font1), "%H:%M:%S", id(homeassistant_time).now()) == id(program3start1).state;'
# - lambda: 'return strftime(0, 0, id(font1), "%H:%M:%S", id(homeassistant_time).now()) == id(program3start2).state;'
then:
- script.execute: retic_program3_run
script:
- id: retic_program1_run
then:
- switch.turn_on: v1
- switch.turn_on: p1
- delay: !lambda 'return id(program1station1runtime).state * 1000;'
- switch.turn_on: v2
- delay: 0.5s
- switch.turn_off: v1
- delay: !lambda 'return id(program1station2runtime).state * 1000;'
- switch.turn_on: v3
- delay: 0.5s
- switch.turn_off: v2
- delay: !lambda 'return id(program1station3runtime).state * 1000;'
- switch.turn_on: v4
- delay: 0.5s
- switch.turn_off: v3
- delay: !lambda 'return id(program1station4runtime).state * 1000;'
- switch.turn_off: p1
- switch.turn_off: v4
- id: retic_program2_run
then:
- switch.turn_on: v1
- switch.turn_on: p1
- delay: !lambda 'return id(program2station1runtime).state * 1000;'
- switch.turn_on: v2
- delay: 0.5s
- switch.turn_off: v1
- delay: !lambda 'return id(program2station2runtime).state * 1000;'
- switch.turn_on: v3
- delay: 0.5s
- switch.turn_off: v2
- delay: !lambda 'return id(program2station3runtime).state * 1000;'
- switch.turn_on: v4
- delay: 0.5s
- switch.turn_off: v3
- delay: !lambda 'return id(program2station4runtime).state * 1000;'
- switch.turn_off: p1
- switch.turn_off: v4
- id: retic_program3_run
then:
- switch.turn_on: v1
- switch.turn_on: p1
- delay: !lambda 'return id(program3station1runtime).state * 1000;'
- switch.turn_on: v2
- delay: 0.5s
- switch.turn_off: v1
- delay: !lambda 'return id(program3station2runtime).state * 1000;'
- switch.turn_on: v3
- delay: 0.5s
- switch.turn_off: v2
- delay: !lambda 'return id(program3station3runtime).state * 1000;'
- switch.turn_on: v4
- delay: 0.5s
- switch.turn_off: v3
- delay: !lambda 'return id(program3station4runtime).state * 1000;'
- switch.turn_off: p1
- switch.turn_off: v4
Basically everything works except for the interval lambda’s where I’m trying to compare time values. The issue is that these are stored as floating point numbers and comparing them in this way is not good, nor is my syntax correct. Hopefully someone can see what I’m trying to achieve and provide a solution.