Hi All,
I’m trying to compile the below code but it fails at the conditions:
for the intervals:
(lines 223 and 224). Any ideas how to fix it would be great. Thanks.
esphome:
name: reticulation_controller
platform: ESP8266
board: nodemcuv2
wifi:
ssid: 'xxx'
password: 'xxx'
manual_ip:
static_ip: 192.168.0.61
gateway: 192.168.0.1
subnet: 255.255.255.0
mqtt:
broker: '192.168.0.13'
username: 'xxx'
password: 'xxx'
discovery: False
api:
# Enable logging
logger:
ota:
password: 'xxx'
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: D5
mode: INPUT_PULLUP
filters:
- delayed_on: 10ms
- platform: gpio
name: "Retic Bore Stop"
pin:
number: D6
mode: INPUT_PULLUP
filters:
- delayed_on: 10ms
switch:
- platform: gpio
name: "Retic Station 1 Valve"
id: v1
icon: mdi:water-pump
pin:
number: D1
inverted: true
- platform: gpio
name: "Retic Station 2 Valve"
id: v2
icon: mdi:water-pump
pin:
number: D2
inverted: true
- platform: gpio
name: "Retic Station 3 Valve"
id: v3
icon: mdi:water-pump
pin:
number: D3
inverted: true
- platform: gpio
name: "Retic Station 4 Valve"
id: v2
icon: mdi:water-pump
pin:
number: D4
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;'
or:
- lambda: 'return id(program1start1).state == homeassistant_time;'
- lambda: 'return id(program1start2).state == homeassistant_time;'
then:
- script.execute: retic_program1_run
- interval: 1min
then:
- if:
condition:
- lambda: 'return id(program2wateringday).state == True;'
or:
- lambda: 'return id(program2start1).state == homeassistant_time;'
- lambda: 'return id(program2start2).state == homeassistant_time;'
then:
- script.execute: retic_program2_run
- interval: 1min
then:
- if:
condition:
- lambda: 'return id(program3wateringday).state == True;'
or:
- lambda: 'return id(program3start1).state == homeassistant_time;'
- lambda: 'return id(program3start2).state == homeassistant_time;'
then:
- script.execute: retic_program3_run
script:
- id: retic_program1_run
then:
- switch.turn_on: v1
- switch.turn_on: v8
- 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: v8
- switch.turn_off: v4
- id: retic_program2_run
then:
- switch.turn_on: v1
- switch.turn_on: v8
- 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: v8
- switch.turn_off: v4
- id: retic_program3_run
then:
- switch.turn_on: v1
- switch.turn_on: v8
- 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: v8
- switch.turn_off: v4
bumping this in case someone can help, plus with the help of someone on Discord I have fixed a few issues, but it still wont compile.
new code:
### 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: 'xxxx'
password: 'xxxx'
manual_ip:
static_ip: 192.168.0.61
gateway: 192.168.0.1
subnet: 255.255.255.0
mqtt:
broker: '192.168.0.13'
username: 'xxxx'
password: 'xxxx'
discovery: False
api:
# Enable logging
logger:
ota:
password: 'xxxx'
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: D5
mode: INPUT_PULLUP
filters:
- delayed_on: 10ms
- platform: gpio
name: "Retic Bore Stop"
pin:
number: D6
mode: INPUT_PULLUP
filters:
- delayed_on: 10ms
switch:
- platform: gpio
name: "Retic Station 1 Valve"
id: v1
icon: mdi:water-pump
pin:
number: D1
inverted: true
- platform: gpio
name: "Retic Station 2 Valve"
id: v2
icon: mdi:water-pump
pin:
number: D2
inverted: true
- platform: gpio
name: "Retic Station 3 Valve"
id: v3
icon: mdi:water-pump
pin:
number: D3
inverted: true
- platform: gpio
name: "Retic Station 4 Valve"
id: v4
icon: mdi:water-pump
pin:
number: D4
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(program1start1).state == homeassistant_time;'
- lambda: 'return id(program1start2).state == homeassistant_time;'
then:
- script.execute: retic_program1_run
- interval: 1min
then:
- if:
condition:
- lambda: 'return id(program2wateringday).state == true;'
then:
- if:
condition:
or:
- lambda: 'return id(program2start1).state == homeassistant_time;'
- lambda: 'return id(program2start2).state == homeassistant_time;'
then:
- script.execute: retic_program2_run
- interval: 1min
then:
- if:
condition:
- lambda: 'return id(program3wateringday).state == true;'
then:
- if:
condition:
or:
- lambda: 'return id(program3start1).state == homeassistant_time;'
- lambda: 'return id(program3start2).state == homeassistant_time;'
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
error:
-
src/main.cpp: In lambda function:
-
src/main.cpp:100:39: error: invalid operands of types ‘float’ and ‘esphome::time::HomeAssistantTime* const’ to binary ‘operator==’
-
return program1start1->state == homeassistant_time;
-
^
-
src/main.cpp: In lambda function:
-
src/main.cpp:103:39: error: invalid operands of types ‘float’ and ‘esphome::time::HomeAssistantTime* const’ to binary ‘operator==’
-
return program2start1->state == homeassistant_time;
-
^
-
src/main.cpp: In lambda function:
-
src/main.cpp:106:39: error: invalid operands of types ‘float’ and ‘esphome::time::HomeAssistantTime* const’ to binary ‘operator==’
-
return program3start1->state == homeassistant_time;
-
^
-
src/main.cpp: In lambda function:
-
src/main.cpp:112:39: error: invalid operands of types ‘float’ and ‘esphome::time::HomeAssistantTime* const’ to binary ‘operator==’
-
return program1start2->state == homeassistant_time;
-
^
-
src/main.cpp: In lambda function:
-
src/main.cpp:115:39: error: invalid operands of types ‘float’ and ‘esphome::time::HomeAssistantTime* const’ to binary ‘operator==’
-
return program2start2->state == homeassistant_time;
-
^
-
src/main.cpp: In lambda function:
-
src/main.cpp:118:39: error: invalid operands of types ‘float’ and ‘esphome::time::HomeAssistantTime* const’ to binary ‘operator==’
-
return program3start2->state == homeassistant_time;
-
^
-
src/main.cpp: In lambda function:
-
src/main.cpp:101:3: warning: control reaches end of non-void function [-Wreturn-type]
-
});
-
^
-
src/main.cpp: In lambda function:
-
src/main.cpp:104:3: warning: control reaches end of non-void function [-Wreturn-type]
-
});
-
^
-
src/main.cpp: In lambda function:
-
src/main.cpp:107:3: warning: control reaches end of non-void function [-Wreturn-type]
-
});
-
^
-
src/main.cpp: In lambda function:
-
src/main.cpp:113:3: warning: control reaches end of non-void function [-Wreturn-type]
-
});
-
^
-
src/main.cpp: In lambda function:
-
src/main.cpp:116:3: warning: control reaches end of non-void function [-Wreturn-type]
-
});
-
^
-
src/main.cpp: In lambda function:
-
src/main.cpp:119:3: warning: control reaches end of non-void function [-Wreturn-type]
-
});
-
^
-
*** [/data/reticulation_controller/.pioenvs/reticulation_controller/src/main.cpp.o] Error 1
Curious why your using mqtt and api for esphome?
I need to pull data from HA so I was using mqtt to retrieve those values but figured I would use the api for the general integration for the rest of it
updated code, still has the same error though
### 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
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: D5
mode: INPUT_PULLUP
filters:
- delayed_on: 10ms
- platform: gpio
name: "Retic Bore Stop"
pin:
number: D6
mode: INPUT_PULLUP
filters:
- delayed_on: 10ms
switch:
- platform: gpio
name: "Retic Station 1 Valve"
id: v1
icon: mdi:water-pump
pin:
number: D1
inverted: true
- platform: gpio
name: "Retic Station 2 Valve"
id: v2
icon: mdi:water-pump
pin:
number: D2
inverted: true
- platform: gpio
name: "Retic Station 3 Valve"
id: v3
icon: mdi:water-pump
pin:
number: D3
inverted: true
- platform: gpio
name: "Retic Station 4 Valve"
id: v4
icon: mdi:water-pump
pin:
number: D4
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(program1start1).state == id(homeassistant_time);'
- lambda: 'return id(program1start2).state == id(homeassistant_time);'
then:
- script.execute: retic_program1_run
- interval: 1min
then:
- if:
condition:
- lambda: 'return id(program2wateringday).state == true;'
then:
- if:
condition:
or:
- lambda: 'return id(program2start1).state == id(homeassistant_time);'
- lambda: 'return id(program2start2).state == id(homeassistant_time);'
then:
- script.execute: retic_program2_run
- interval: 1min
then:
- if:
condition:
- lambda: 'return id(program3wateringday).state == true;'
then:
- if:
condition:
or:
- lambda: 'return id(program3start1).state == id(homeassistant_time);'
- lambda: 'return id(program3start2).state == id(homeassistant_time);'
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
I’m getting closer but still need some help with the time comparison function I’m trying to do:
lambda: 'return strftime(0, 0, tmp, "%H:%M:%S", id(program1start1).state) == id(homeassistant_time).now();'
fails to compile. I have put ‘tmp’ in the ‘font’ section of the strftime for now until I can find a solution. Any help would be awesome
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.
It seems the time attributes you’ve used on the MQTT sensor aren’t supported, it’s only valid when used in conjunction with .now()
.
I’ve been doing a little bit of experimenting, could you tell me what a message from program1start1
looks like?
Alternatively, ESPHome now supported user-defined services allowing you to get data out of HA.
Program 1time1 comes from an input_datetime entity with only a time component. From the ESPhome docs, the mqtt_subscribe sensor is then saving this as a floating point number.
The variables in the link you supplied look interesting but it doesn’t seem apparent how I could use that feature to bring in my input_datetime entities… I hope they can though