I don’t know why its error after error but, its driving me nuts. I’m just trying to see if temp1 < temp2 - variable.
- platform: template
name: "Heat Mode"
id: heat_mode_update
update_interval: 30s
on_value:
if:
condition:
lambda: return (id(supply_air_temp).state > (id(return_air_temp).state + (id(heat_deg).state)));
then:
- lambda: id(heat_mode).publish_state(true);
- lambda: id(cooling_mode).publish_state(false);
- lambda: id(standby_mode).publish_state(false);
- platform: template
name: "Standby Mode"
id: standby_mode_update
update_interval: 30s
on_value:
if:
condition:
or:
- binary_sensor.is_on: heat_mode
- binary_sensor.is_on: cooling_mode
then:
- lambda: id(standby_mode).publish_state(true);
- platform: template
name: "Cool Mode"
id: cool_mode_update
update_interval: 30s
on_value:
if:
condition:
lambda: return (id(supply_air_temp).state < (id(return_air_temp).state - (id(ac_deg).state)));
then:
- lambda: id(cooling_mode).publish_state(true);
- lambda: id(heat_mode).publish_state(false);
- lambda: id(standby_mode).publish_state(false);
/config/esphome/smith.yaml: In lambda function:
/config/esphome/smith.yaml:195:32: error: 'class esphome::dallas::DallasComponent' has no member named 'state'
lambda: return (id(supply_air_temp).state > (id(return_air_temp).state + (id(heat_deg).state)));
^
/config/esphome/smith.yaml:195:58: error: 'class esphome::dallas::DallasComponent' has no member named 'state'
lambda: return (id(supply_air_temp).state > (id(return_air_temp).state + (id(heat_deg).state)));
^
/config/esphome/smith.yaml:195:85: error: request for member 'state' in 'heat_deg->esphome::globals::RestoringGlobalsComponent<T>::value<int>()', which is of non-class type 'int'
lambda: return (id(supply_air_temp).state > (id(return_air_temp).state + (id(heat_deg).state)));
^
/config/esphome/smith.yaml: In lambda function:
/config/esphome/smith.yaml:225:32: error: 'class esphome::dallas::DallasComponent' has no member named 'state'
lambda: return (id(supply_air_temp).state < (id(return_air_temp).state - (id(ac_deg).state)));
^
/config/esphome/smith.yaml:225:58: error: 'class esphome::dallas::DallasComponent' has no member named 'state'
lambda: return (id(supply_air_temp).state < (id(return_air_temp).state - (id(ac_deg).state)));
^
/config/esphome/smith.yaml:225:83: error: request for member 'state' in 'ac_deg->esphome::globals::RestoringGlobalsComponent<T>::value<int>()', which is of non-class type 'int'
lambda: return (id(supply_air_temp).state < (id(return_air_temp).state - (id(ac_deg).state)));
mulcmu
December 6, 2022, 12:23am
2
For the global values try .value or .value() instead of .state.
Not sure what is going on with the Dallas, can you post the yaml config for those?
zoogara
(Daryl)
December 6, 2022, 2:37am
3
For starters - for single line lambdas it is good practice to enclose them in quotes - e.g:
- lambda: 'id(standby_mode).publish_state(true); '
id(supply_air_temp).state
should work fine, so yes - post the sensor config.
yes, thanks.
dallas:
- pin: GPIO23
update_interval: 10s
id: return_air_temp
- pin: GPIO22
update_interval: 10s
id: supply_air_temp
- platform: dallas
address: 0xA40000031F055028
name: "Supply Air Temp"
dallas_id: supply_air_temp
unit_of_measurement: "C"
device_class: "temperature"
state_class: "measurement"
filters:
- sliding_window_moving_average:
window_size: 15
send_every: 15
- debounce: 0.25s
# Dallas Sensor 2
- platform: dallas
address: 0xDD0000031EFB0428
name: "Return Air Temp"
dallas_id: return_air_temp
unit_of_measurement: "C"
device_class: "temperature"
state_class: "measurement"
filters:
- sliding_window_moving_average:
window_size: 15
send_every: 15
- debounce: 0.25s
here is all of it if that helps or if anyone has critiques or suggestions I can improve on.
globals:
- id: ac_deg
type: int
restore_value: yes
initial_value: "4"
- id: heat_deg
type: int
restore_value: yes
initial_value: "4"
substitutions:
devicename: smith # Name. Lowercase only, Used for Device Name and Entities
upper_devicename: Smith Heat/Cool
interval0: "2"
interval1: "3"
interval2: "4"
interval3: "5"
interval4: "6"
interval5: "2"
interval6: "3"
interval7: "4"
interval8: "5"
interval9: "6"
esphome:
name: $devicename
comment: Heat/Cool Capacity Controller
project:
name: "Michael_Smith.Capacity_Controller"
version: "1.0.0"
# Enter Standby Mode If ESP32 is Shut Down
on_shutdown:
priority: 700
then:
- switch.turn_off: capacity_75
- switch.turn_off: capacity_50
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "dCBKRt+U83BU14lOjmkWvoJDEXeZYRySs5XYUBGhCTk="
ota:
password: "69416d378e2dcbdb9d43f646bbbf8e72"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Smith Fallback Hotspot"
password: "YFpp0NDHnJV8"
captive_portal:
# Web Server to access logs, view and edit configurable settings
web_server:
port: 80
# Dallas Temp Sensor
dallas:
- pin: GPIO23
update_interval: 10s
id: return_air_temp
- pin: GPIO22
update_interval: 10s
id: supply_air_temp
text_sensor:
# ESPHome version as sensor.
- platform: version
name: $devicename ESPHome Version
#--------------------------------------------------------------------------------------------------------------------------------------------#
# WiFi information as sensors.
- platform: wifi_info
ip_address:
name: $devicename IP
ssid:
name: $devicename SSID
bssid:
name: $devicename BSSID
#--------------------------------------------------------------------------------------------------------------------------------------------#
# Home Assistant Input Select Sensor for AC Degree Difference
select:
- platform: template
id: ac_deg_diff
name: A/C Degree Difference
icon: mdi:timer-outline
optimistic: true
restore_value: true
initial_option: "4 Degrees"
options:
- $interval0 Degrees
- $interval1 Degrees
- $interval2 Degrees
- $interval3 Degrees
- $interval4 Degrees
on_value:
then:
- globals.set:
id: ac_deg
value: !lambda 'return x;'
# Home Assistant Input Select Sensor for Heat Degree Difference
- platform: template
id: heat_deg_diff
name: Heat Degree Difference
icon: mdi:timer-outline
optimistic: true
restore_value: true
initial_option: "4 Degrees"
options:
- $interval5 Degrees
- $interval6 Degrees
- $interval7 Degrees
- $interval8 Degrees
- $interval9 Degrees
on_value:
then:
- globals.set:
id: heat_deg
value: !lambda 'return x;'
sensor:
# Home Assistant Up Time Sensor
- platform: uptime
name: "heat/cool uptime"
#--------------------------------------------------------------------------------------------------------------------------------------------#
# Dallas Sensor 1
- platform: dallas
address: 0xA40000031F055028
name: "Supply Air Temp"
dallas_id: supply_air_temp
unit_of_measurement: "C"
device_class: "temperature"
state_class: "measurement"
filters:
- sliding_window_moving_average:
window_size: 15
send_every: 15
- debounce: 0.25s
# Dallas Sensor 2
- platform: dallas
address: 0xDD0000031EFB0428
name: "Return Air Temp"
dallas_id: return_air_temp
unit_of_measurement: "C"
device_class: "temperature"
state_class: "measurement"
filters:
- sliding_window_moving_average:
window_size: 15
send_every: 15
- debounce: 0.25s
#--------------------------------------------------------------------------------------------------------------------------------------------#
# Template Sensors
- platform: template
name: "Heat Mode"
id: heat_mode_update
update_interval: 30s
on_value:
if:
condition:
lambda: return (id(supply_air_temp).state > (id(return_air_temp).state + (id(heat_deg).state)));
then:
- lambda: 'id(heat_mode).publish_state(true);'
- lambda: 'id(cooling_mode).publish_state(false);'
- lambda: 'id(standby_mode).publish_state(false);'
- platform: template
name: "Standby Mode"
id: standby_mode_update
update_interval: 30s
accuracy_decimals: 1
on_value:
if:
condition:
or:
- binary_sensor.is_on: heat_mode
- binary_sensor.is_on: cooling_mode
then:
- lambda: 'id(standby_mode).publish_state(true);'
- platform: template
name: "Cool Mode"
id: cool_mode_update
update_interval: 30s
on_value:
if:
condition:
lambda: return (id(supply_air_temp).state < (id(return_air_temp).state - (id(ac_deg).state)));
then:
- lambda: 'id(heat_mode).publish_state(false);'
- lambda: 'id(cooling_mode).publish_state(true);'
- lambda: 'id(standby_mode).publish_state(false);'
#--------------------------------------------------------------------------------------------------------------------------------------------#
# Mode Status Sensor
binary_sensor:
- platform: template
name: "Cooling Mode"
id: cooling_mode
device_class: cold
- platform: template
name: "Heat Mode"
id: heat_mode
device_class: heat
- platform: template
name: "standby mode"
id: standby_mode
#--------------------------------------------------------------------------------------------------------------------------------------------#
# Control/Capacity Switches
switch:
- platform: template
name: "Standby Mode"
turn_on_action:
- switch.turn_off: capacity_75
- switch.turn_off: capacity_50
turn_off_action:
- switch.turn_off: capacity_75
- switch.turn_off: capacity_50
- platform: template
name: "100% Capacity"
id: capacity_100
turn_on_action:
- switch.turn_off: capacity_75
- switch.turn_off: capacity_50
- platform: gpio
pin: GPIO19
name: "75% Capacity"
id: capacity_75
interlock: [capacity_50]
interlock_wait_time: 2s # 2 second delay for Relay 2 HIGH POWER
- platform: gpio
pin: GPIO17
name: "50% Capacity"
id: capacity_50
interlock: [capacity_75]
interlock_wait_time: 2s # 2 second delay for Relay 1 LOW POWER
mulcmu
December 6, 2022, 4:26pm
6
I think the id
used for the lambda to get the temperature reading should be with the temperature configuration and not the dallas
bus configuration.
dallas:
- pin: GPIO23
update_interval: 10s
id: return_air_temp_bus #edit
- pin: GPIO22
update_interval: 10s
id: supply_air_temp_bus #edit
- platform: dallas
address: 0xA40000031F055028
name: "Supply Air Temp"
dallas_id: supply_air_temp_bus #edit
id: supply_air_temp #edit add id:
unit_of_measurement: "C"
device_class: "temperature"
state_class: "measurement"
filters:
- sliding_window_moving_average:
window_size: 15
send_every: 15
- debounce: 0.25s
#similar edits for return side
It throws an error when trying to split them up with different ID’s you cant see it in the screen shot but I changed the dallas id like your suggestion
mulcmu
December 7, 2022, 5:35pm
8
It looks like changing the id:
around is a quirk or bug in the user interface. I got the same warning when making the change in the editor but disappeared after a HA restart.
To access the global values just the id(global) is all that is needed, no .state or .value necessary.
The below configuration compiles for me on 2022.11.1. I made one other fix to the template select lambdas.
globals:
- id: ac_deg
type: int
restore_value: yes
initial_value: "4"
- id: heat_deg
type: int
restore_value: yes
initial_value: "4"
substitutions:
devicename: smith # Name. Lowercase only, Used for Device Name and Entities
upper_devicename: Smith Heat/Cool
interval0: "2"
interval1: "3"
interval2: "4"
interval3: "5"
interval4: "6"
interval5: "2"
interval6: "3"
interval7: "4"
interval8: "5"
interval9: "6"
esphome:
name: $devicename
comment: Heat/Cool Capacity Controller
project:
name: "Michael_Smith.Capacity_Controller"
version: "1.0.0"
# Enter Standby Mode If ESP32 is Shut Down
on_shutdown:
priority: 700
then:
- switch.turn_off: capacity_75
- switch.turn_off: capacity_50
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "dCBKRt+U83BU14lOjmkWvoJDEXeZYRySs5XYUBGhCTk="
ota:
password: "69416d378e2dcbdb9d43f646bbbf8e72"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Smith Fallback Hotspot"
password: "YFpp0NDHnJV8"
captive_portal:
# Web Server to access logs, view and edit configurable settings
web_server:
port: 80
# Dallas Temp Sensor
dallas:
- pin: GPIO23
update_interval: 10s
id: return_air_temp_bus
- pin: GPIO22
update_interval: 10s
id: supply_air_temp_bus
text_sensor:
# ESPHome version as sensor.
- platform: version
name: $devicename ESPHome Version
#--------------------------------------------------------------------------------------------------------------------------------------------#
# WiFi information as sensors.
- platform: wifi_info
ip_address:
name: $devicename IP
ssid:
name: $devicename SSID
bssid:
name: $devicename BSSID
#--------------------------------------------------------------------------------------------------------------------------------------------#
# Home Assistant Input Select Sensor for AC Degree Difference
select:
- platform: template
id: ac_deg_diff
name: A/C Degree Difference
icon: mdi:timer-outline
optimistic: true
restore_value: true
initial_option: "4 Degrees"
options:
- $interval0 Degrees
- $interval1 Degrees
- $interval2 Degrees
- $interval3 Degrees
- $interval4 Degrees
on_value:
then:
- lambda: 'id(ac_deg)=String(x.c_str()).toInt();'
# Home Assistant Input Select Sensor for Heat Degree Difference
- platform: template
id: heat_deg_diff
name: Heat Degree Difference
icon: mdi:timer-outline
optimistic: true
restore_value: true
initial_option: "4 Degrees"
options:
- $interval5 Degrees
- $interval6 Degrees
- $interval7 Degrees
- $interval8 Degrees
- $interval9 Degrees
on_value:
then:
- lambda: 'id(heat_deg)=String(x.c_str()).toInt();'
sensor:
# Home Assistant Up Time Sensor
- platform: uptime
name: "heat/cool uptime"
#--------------------------------------------------------------------------------------------------------------------------------------------#
# Dallas Sensor 1
- platform: dallas
address: 0xA40000031F055028
name: "Supply Air Temp"
dallas_id: supply_air_temp_bus
id: supply_air_temp
unit_of_measurement: "C"
device_class: "temperature"
state_class: "measurement"
filters:
- sliding_window_moving_average:
window_size: 15
send_every: 15
- debounce: 0.25s
# Dallas Sensor 2
- platform: dallas
address: 0xDD0000031EFB0428
name: "Return Air Temp"
dallas_id: return_air_temp_bus
id: return_air_temp
unit_of_measurement: "C"
device_class: "temperature"
state_class: "measurement"
filters:
- sliding_window_moving_average:
window_size: 15
send_every: 15
- debounce: 0.25s
#--------------------------------------------------------------------------------------------------------------------------------------------#
# Template Sensors
- platform: template
name: "Heat Mode"
id: heat_mode_update
update_interval: 30s
on_value:
if:
condition:
lambda: 'return (id(supply_air_temp).state > (id(return_air_temp).state + id(heat_deg))); '
then:
- lambda: 'id(heat_mode).publish_state(true);'
- lambda: 'id(cooling_mode).publish_state(false);'
- lambda: 'id(standby_mode).publish_state(false);'
- platform: template
name: "Standby Mode"
id: standby_mode_update
update_interval: 30s
accuracy_decimals: 1
on_value:
if:
condition:
or:
- binary_sensor.is_on: heat_mode
- binary_sensor.is_on: cooling_mode
then:
- lambda: 'id(standby_mode).publish_state(true);'
- platform: template
name: "Cool Mode"
id: cool_mode_update
update_interval: 30s
on_value:
if:
condition:
lambda: 'return (id(supply_air_temp).state < (id(return_air_temp).state - id(ac_deg)));'
then:
- lambda: 'id(heat_mode).publish_state(false);'
- lambda: 'id(cooling_mode).publish_state(true);'
- lambda: 'id(standby_mode).publish_state(false);'
#--------------------------------------------------------------------------------------------------------------------------------------------#
# Mode Status Sensor
binary_sensor:
- platform: template
name: "Cooling Mode"
id: cooling_mode
device_class: cold
- platform: template
name: "Heat Mode"
id: heat_mode
device_class: heat
- platform: template
name: "standby mode"
id: standby_mode
#--------------------------------------------------------------------------------------------------------------------------------------------#
# Control/Capacity Switches
switch:
- platform: template
name: "Standby Mode"
turn_on_action:
- switch.turn_off: capacity_75
- switch.turn_off: capacity_50
turn_off_action:
- switch.turn_off: capacity_75
- switch.turn_off: capacity_50
- platform: template
name: "100% Capacity"
id: capacity_100
turn_on_action:
- switch.turn_off: capacity_75
- switch.turn_off: capacity_50
- platform: gpio
pin: GPIO19
name: "75% Capacity"
id: capacity_75
interlock: [capacity_50]
interlock_wait_time: 2s # 2 second delay for Relay 2 HIGH POWER
- platform: gpio
pin: GPIO17
name: "50% Capacity"
id: capacity_50
interlock: [capacity_75]
interlock_wait_time: 2s # 2 second delay for Relay 1 LOW POWER
yes, i figured that out yesterday. I was trying to call the dallas component instead of the dallas sensor and giving it an ID was the issue. Its always the last thing you check too…