Would somebody please help me out…?
I’ve been trying to get this going on and off for a few weeks now, and I was hoping that now that my Sonoff 4CH is connected up that the issue would go away, but it hasn’t.
With all cycles off, I get this and everything looks normal:
However, when I turn a cycle on, I get this red card most of the time:
I’ve selected the zone switches here:
I can see my controller signal strength here:
![image](https://community-assets.home-assistant.io/original/3X/1/0/10b72cca32bece7fd8e953d258a7e98d30eaca89.png)
This is a copy of the code in the red card
ButtonCardJSTemplateError: TypeError: Cannot read property 'state' of undefined in 'if (states['input_boolean.irrigation_master_control_switch'].state == 'off') return 'SYSTEM IS...'
tap_action:
action: |
[[[
if (states['binary_sensor.irrigation_cycle_start_clash'].state == 'on')
return 'call-service';
else
return 'none';
]]]
service: browser_mod.popup
service_data:
title: ❗ CYCLE SCHEDULE CLASH
card:
type: markdown
content: >
#### WARNING! You have overlapping cycle schedules...
{{ state_attr('binary_sensor.irrigation_cycle_start_clash',
'clash_text') }}
Please check and correct.
deviceID:
- this
style:
$: |
.mdc-dialog {
backdrop-filter: blur(5px);
}
.mdc-dialog .mdc-dialog__container .mdc-dialog__surface {
border-radius: 1em;
box-shadow: 0em 0em 0.5em;
}
type: 'custom:button-card'
group_expand: false
hold_action:
action: none
double_tap_action:
action: none
layout: vertical
size: 40%
color_type: icon
show_name: true
show_state: false
show_icon: false
show_units: true
show_label: true
show_entity_picture: false
show_live_stream: false
card_size: 3
entity: input_text.irrigation_current_status
triggers_update:
- group.irrigation_group_cycle1_every_day
- group.irrigation_group_cycle1_mon
- group.irrigation_group_cycle1_tue
- group.irrigation_group_cycle1_wed
- group.irrigation_group_cycle1_thu
- group.irrigation_group_cycle1_fri
- group.irrigation_group_cycle1_sat
- group.irrigation_group_cycle1_sun
- group.irrigation_group_cycle2_every_day
- group.irrigation_group_cycle2_mon
- group.irrigation_group_cycle2_tue
- group.irrigation_group_cycle2_wed
- group.irrigation_group_cycle2_thu
- group.irrigation_group_cycle2_fri
- group.irrigation_group_cycle2_sat
- group.irrigation_group_cycle2_sun
name: |
[[[
if (states['input_boolean.irrigation_master_control_switch'].state == 'off')
return 'SYSTEM IS OFF';
else
var today = new Date();
var weekday = new Array(7);
weekday[0] = "sun";
weekday[1] = "mon";
weekday[2] = "tue";
weekday[3] = "wed";
weekday[4] = "thu";
weekday[5] = "fri";
weekday[6] = "sat";
var day_today = weekday[today.getDay()];
var day_tomorrow = weekday[(today.getDay() + 1) % 7];
if (states['group.irrigation_group_cycle1_every_day'].state == 'on' ||
states['group.irrigation_group_cycle1_' + day_today].state == 'on')
var cycle1_runs_today = true;
else
var cycle1_runs_today = false;
if (states['group.irrigation_group_cycle2_every_day'].state == 'on' ||
states['group.irrigation_group_cycle2_' + day_today].state == 'on')
var cycle2_runs_today = true;
else
var cycle2_runs_today = false;
if (states['group.irrigation_group_cycle1_every_day'].state == 'on' ||
states['group.irrigation_group_cycle1_' + day_tomorrow].state == 'on')
var cycle1_runs_tomorrow = true;
else
var cycle1_runs_tomorrow = false;
if (states['group.irrigation_group_cycle2_every_day'].state == 'on' ||
states['group.irrigation_group_cycle2_' + day_tomorrow].state == 'on')
var cycle2_runs_tomorrow = true;
else
var cycle2_runs_tomorrow = false;
var time_now = states['sensor.time'].state;
var cycle1_schedule_enabled = states['input_boolean.irrigation_cycle1_schedule_enabled'].state;
var cycle2_schedule_enabled = states['input_boolean.irrigation_cycle2_schedule_enabled'].state;
var cycle1_start_time = states['input_datetime.irrigation_cycle1_start_time'].state.substr(0, 5);
var cycle2_start_time = states['input_datetime.irrigation_cycle2_start_time'].state.substr(0, 5);
var cycle1_name = states['input_text.irrigation_cycle1_name'].state;
var cycle2_name = states['input_text.irrigation_cycle2_name'].state;
var cycle3_name = states['input_text.irrigation_cycle3_name'].state;
var cycle1_running = states['input_boolean.irrigation_cycle1_running'].state;
var cycle2_running = states['input_boolean.irrigation_cycle2_running'].state;
var cycle3_running = states['input_boolean.irrigation_cycle3_running'].state;
if (cycle1_running == 'on')
return cycle1_name;
else if (cycle2_running == 'on')
return cycle2_name;
else if (cycle3_running == 'on')
return cycle3_name;
else if (cycle1_schedule_enabled == 'on' && cycle1_runs_today && cycle1_start_time > time_now)
return cycle1_name + ' at ' + cycle1_start_time;
else if (cycle2_schedule_enabled == 'on' && cycle2_runs_today && cycle2_start_time > time_now)
return cycle2_name + ' at ' + cycle2_start_time;
else if (cycle1_schedule_enabled == 'on' && cycle1_runs_tomorrow)
return 'Tomorrow at ' + cycle1_start_time;
else if (cycle2_schedule_enabled == 'on' && cycle2_runs_tomorrow)
return 'Tomorrow at ' + cycle2_start_time;
else return 'NOTHING SCHEDULED';
]]]
label: |
[[[
var cycle1_running = states['input_boolean.irrigation_cycle1_running'].state;
var cycle2_running = states['input_boolean.irrigation_cycle2_running'].state;
var cycle3_running = states['input_boolean.irrigation_cycle3_running'].state;
if (cycle1_running == 'on')
return 'RUNNING: ';
else if (cycle2_running == 'on')
return 'RUNNING: ';
else if (cycle3_running == 'on')
return 'RUNNING: ';
else
return 'NEXT RUN: ';
]]]
styles:
grid:
- grid-template-areas: '"l n clash_icon warning"'
- grid-template-columns: min-content min-content 10% 1fr
- grid-template-rows: 1fr
card:
- font-family: |
[[[
return states['input_text.irrigation_ui_font_family'].state
]]]
- background: none
- box-shadow: none
- padding: 0.3em 0em 0em 0.5em
name:
- justify-self: start
- align-self: start
- padding: 0em 0.5em
- color: |
[[[
if (states['input_boolean.irrigation_master_control_switch'].state == 'off')
return 'rgb(255, 165, 0)';
else
return 'var(--secondary-text-color)';
]]]
label:
- color: var(--primary-text-color)
- justify-self: start
- align-self: start
custom_fields:
clash_icon:
- padding: 0em 0.5em
- color: |
[[[
switch(states['binary_sensor.irrigation_cycle_start_clash'].state) {
case 'on':
return 'rgb(255, 165, 0)';
case 'off':
return 'transparent';
}
]]]
warning:
- color: 'rgb(255, 165, 0)'
- justify-self: end
custom_fields:
clash_icon: |
[[[
return '<ha-icon icon="mdi:alert-rhombus-outline"></ha-icon>';
]]]
warning: |
[[[
switch(states['input_boolean.irrigation_master_control_switch'].state) {
case 'off':
return '';
case 'on':
if (states['input_boolean.irrigation_testing_mode'].state == 'on')
return '(Testing Mode is On)';
}
]]]
default_color: var(--primary-text-color)
color_off: var(--paper-item-icon-color)
color_on: var(--paper-item-icon-active-color)
lock:
enabled: false
duration: 5
unlock: tap
This is my sonoff esphome yaml
binary_sensor:
- platform: gpio
pin:
number: GPIO0
mode: INPUT_PULLUP
inverted: True
name: "Zone 1"
- platform: gpio
pin:
number: GPIO9
mode: INPUT_PULLUP
inverted: True
name: "Zone 2"
- platform: gpio
pin:
number: GPIO10
mode: INPUT_PULLUP
inverted: True
name: "Zone 3"
- platform: gpio
pin:
number: GPIO14
mode: INPUT_PULLUP
inverted: True
name: "Zone 4"
- platform: status
name: "ESPHome Irrigation Controller Status"
switch:
- platform: gpio
name: "Zone Relay 1"
pin: GPIO12
- platform: gpio
name: "Zone Relay 2"
pin: GPIO5
- platform: gpio
name: "Zone Relay 3"
pin: GPIO4
- platform: gpio
name: "Zone Relay 4"
pin: GPIO15
output:
# Register the blue LED as a dimmable output ....
- platform: esp8266_pwm
id: blue_led
pin: GPIO13
inverted: True
light:
# ... and then make a light out of it.
- platform: monochromatic
name: "EspHome Irrigation Controller Blue LED"
output: blue_led
sensor:
- platform: wifi_signal
name: ESPHome Irrigation Controller Wifi Strength
update_interval: 60s
- platform: uptime
name: ESPHome Irrigation Controller Uptime
filters:
- lambda: return x / 60.0;
unit_of_measurement: minutes
Sorry for the long post, I’m just stuck and don’t know where I’ve gone wrong.
I’d really appreciate some help here, I’m at loss of where to start looking.