This is the esp device yaml
esphome:
name: boiler-control
platform: ESP8266
board: d1_mini
on_boot:
then:
# read the RTC time once when the system boots
ds1307.read_time:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
fast_connect: true
api:
password: !secret api_password
services:
- service: update_nextion
then:
- lambda: 'id(disp1)->upload_tft();'
ota:
password: !secret ota_password
logger:
baud_rate: 0 # Disable UART logging (pins GPIO1/3 are used for Nextion communication)
# Enable fallback hotspot (captive portal) in case wifi connection fails
level: VERY_VERBOSE
logs:
api: VERY_VERBOSE
homeassistant: VERY_VERBOSE
nextion: VERY_VERBOSE
api.service: VERY_VERBOSE
sensor: VERY_VERBOSE
scheduler: DEBUG
captive_portal:
uart:
rx_pin: D6
tx_pin: D7
baud_rate: 115200
time:
- platform: ds1307
id: rtc_time
# repeated synchronization is not necessary unless the external RTC
# is much more accurate than the internal clock
update_interval: never
- platform: homeassistant
# instead try to synchronize via network repeatedly ...
on_time_sync:
then:
# ... and update the RTC when the synchronization was successful
ds1307.write_time:
http_request:
i2c:
sda: D2
scl: D1
scan: true
dallas:
- pin: D4
update_interval: 30s
sensor:
- platform: dallas
name: "Tank Top Temperature"
address: 0x8C01202253CD1E28
id: toptemp
- platform: homeassistant
id: sun_elevation
entity_id: sensor.sun_elevation
internal: true
- platform: homeassistant # Office temperature
id: temperature_office
entity_id: sensor.office_temperature_temperature
internal: true
- platform: wifi_signal
name: "WiFi Signal Boiler"
update_interval: 60s
id: wifi_boiler
text_sensor:
- platform: homeassistant
entity_id: sensor.bschet
name: "esp bsched rtn"
id: bsched
on_value:
then:
- lambda: |-
ESP_LOGD("main", "The current schedba is %s", x.c_str());
- platform: homeassistant
name: "esp input test rtn"
entity_id: input_text.text1
id: input_text1
on_value:
then:
- lambda: ESP_LOGD("main", "The current schedbb is %s", x.c_str());
- platform: template
id: bscheda
internal: true
lambda: |-
return {"Hello World"};
update_interval: 60s
# Select setup
select:
- platform: template
name: "Boiler State"
id: boil_mode
optimistic: true
options:
- 'Off'
- 'Manual On'
- 'Auto'
- 'Local'
initial_option: 'Off'
on_value:
then:
- logger.log:
format: "$$$$$$$$$$$$$$$ Chosen option: %s"
args: ["x.c_str()"]
- script.execute: adjust_buttons_pagew
- script.execute: adjust_buttons_pageb
globals:
- id: first_page # First page of the display?
type: bool
restore_value: no
initial_value: 'false'
- id: current_brightness # Is display on?
type: float
restore_value: no
initial_value: '-1.0'
- id: wifi_state
type: bool
restore_value: no
initial_value: 'false'
- id: current_mode # 0= OFF, MAN_ON, AUTO, = LOCAL
type: int
initial_value: '0'
restore_value: yes
- id: run_state # false not runing - true running
type: bool
restore_value: no
initial_value: 'false'
- id: auto_btn_img_idx
type: int
restore_value: no
initial_value: '0'
display:
- platform: nextion
id: disp1
update_interval: 10s
tft_url: 'http://rhome:8123/local/boiler5.tft'
lambda: |-
ESP_LOGD("main", "enter display loop");
if (id(first_page)) {
it.goto_page("weather");
auto time = id(rtc_time).now();
auto day_text = time.strftime("%a");
it.set_component_text("dayw",day_text.c_str());
it.set_component_text_printf("hourw","%02d:",time.hour);
it.set_component_text_printf("minutew","%02d",time.minute);
it.set_component_text_printf("statuslabelw","s: %s",id(bsched).state.c_str());
id(adjust_buttons_pagew).execute();
if (id(wifi_state)) {
it.send_command_printf ("wifiiconw.picc=0");
}
else {
it.send_command_printf ("wifiiconw.picc=1");
}
}
else
{
it.goto_page("temperature");
it.set_component_text_printf("topt","%2.1f",id(toptemp).state);
it.set_component_text_printf("bottemp","%2.1f",id(temperature_office).state);
it.set_component_text_printf("ladtemp","%2.1f",id(temperature_office).state);
it.set_component_text_printf("furtemp","%2.1f",id(temperature_office).state);
it.set_component_text_printf("rettemp","%2.1f",id(temperature_office).state);
it.set_component_text_printf("blendtemp","%2.1f",id(toptemp).state);
it.set_component_text_printf("statuslabel","s: %s",id(bsched).state.c_str());
auto time = id(rtc_time).now();
auto day_text = time.strftime("%a");
it.set_component_text("day",day_text.c_str());
it.set_component_text_printf("hour","%02d:",time.hour);
it.set_component_text_printf("minute","%02d",time.minute);
id(adjust_buttons_pageb).execute();
if (id(wifi_state)) {
it.send_command_printf ("wifiicon.picc=0");
}
else {
it.send_command_printf ("wifiicon.picc=1");
}
}
id(first_page) = !id(first_page); // Switch page
ESP_LOGD("main", "EXIT display loop");
ESP_LOGD("main", "The current sched is %s", id(bsched).state.c_str());
binary_sensor:
- platform: status
name: "Boiler Status"
id: boiler_status
- platform: nextion
page_id: 0
component_id: 14
id: off_btn
name: "Set Off"
internal: true
on_release:
lambda: |-
auto call = id(boil_mode).make_call();
call.set_option("Off");
call.perform();
- platform: nextion
page_id: 0
component_id: 15
id: man_btn
name: "Set Manual"
internal: true
on_release:
lambda: |-
auto call = id(boil_mode).make_call();
call.set_option("Manual On");
call.perform();
- platform: nextion
page_id: 0
component_id: 16
id: auto_btn
name: "Set Auto"
internal: true
on_release:
if:
condition:
lambda: 'return id(wifi_state);'
then:
lambda: |-
auto call = id(boil_mode).make_call();
call.set_option("Auto");
call.perform();
else:
lambda: |-
auto call = id(boil_mode).make_call();
call.set_option("Local");
call.perform();
- platform: nextion
page_id: 1
component_id: 9
id: off_btnw
name: "Set Offw"
internal: true
on_release:
lambda: |-
auto call = id(boil_mode).make_call();
call.set_option("Off");
call.perform();
- platform: nextion
page_id: 1
component_id: 8
id: man_btnw
name: "Set Manualw"
internal: true
on_release:
lambda: |-
auto call = id(boil_mode).make_call();
call.set_option("Manual On");
call.perform();
- platform: nextion
page_id: 1
component_id: 10
id: auto_btnw
name: "Set Autow"
internal: true
on_release:
if:
condition:
lambda: 'return id(wifi_state);'
then:
lambda: |-
auto call = id(boil_mode).make_call();
call.set_option("Auto");
call.perform();
else:
lambda: |-
auto call = id(boil_mode).make_call();
call.set_option("Local");
call.perform();
- platform: status
id: apistatus
name: "Boiler API Status"
internal: true
on_state: # based on wifi connection, we set the global variable here. This way it will be stored and valid upon refresh
- if:
condition:
api.connected:
then:
- globals.set:
id: wifi_state
value: 'true'
- lambda: |-
id(disp1).send_command_printf ("wifiicon.picc=0");
else:
- globals.set:
id: wifi_state
value: 'false'
- lambda: |-
id(disp1).send_command_printf ("wifiicon.picc=1");
script:
- id: adjust_buttons_pageb # adjust button setting on boiler page
then:
- lambda: |-
id(auto_btn_img_idx) = 0;
if ( !id(wifi_state))
id(auto_btn_img_idx) = 3;
- if:
condition:
- lambda: |-
return (strcmp( id(boil_mode).state.c_str(), "Off") == 0);
then:
lambda: |-
id(disp1).send_command_printf ("off_btn.picc=1");
id(disp1).send_command_printf ("man_btn.picc=0");
id(disp1).send_command_printf ("auto_btn.picc=%i", id(auto_btn_img_idx));
- if:
condition:
- lambda: |-
return (strcmp( id(boil_mode).state.c_str(), "Manual On") == 0);
then:
lambda: |-
id(disp1).send_command_printf ("off_btn.picc=0");
id(disp1).send_command_printf ("man_btn.picc=1");
id(disp1).send_command_printf ("auto_btn.picc=%i", id(auto_btn_img_idx));
- if:
condition:
- lambda: |-
return (strcmp( id(boil_mode).state.c_str(), "Auto") == 0);
then:
lambda: |-
id(disp1).send_command_printf ("off_btn.picc=0");
id(disp1).send_command_printf ("man_btn.picc=0");
id(disp1).send_command_printf ("auto_btn.picc=1");
- if:
condition:
- lambda: |-
return (strcmp( id(boil_mode).state.c_str(), "Local") == 0);
then:
lambda: |-
id(disp1).send_command_printf ("off_btn.picc=0");
id(disp1).send_command_printf ("man_btn.picc=0");
id(disp1).send_command_printf ("auto_btn.picc=2");
- id: adjust_buttons_pagew # adjust button setting on weather page
then:
- lambda: |-
id(auto_btn_img_idx) = 0;
if ( !id(wifi_state))
id(auto_btn_img_idx) = 3;
- if:
condition:
- lambda: |-
return (strcmp( id(boil_mode).state.c_str(), "Off") == 0);
then:
lambda: |-
id(disp1).send_command_printf ("off_btnw.picc=1");
id(disp1).send_command_printf ("man_btnw.picc=0");
id(disp1).send_command_printf ("auto_btnw.picc=%i", id(auto_btn_img_idx));
- if:
condition:
- lambda: |-
return (strcmp( id(boil_mode).state.c_str(), "Manual On") == 0);
then:
lambda: |-
id(disp1).send_command_printf ("off_btnw.picc=0");
id(disp1).send_command_printf ("man_btnw.picc=1");
id(disp1).send_command_printf ("auto_btnw.picc=%i", id(auto_btn_img_idx));
- if:
condition:
- lambda: |-
return (strcmp( id(boil_mode).state.c_str(), "Auto") == 0);
then:
lambda: |-
id(disp1).send_command_printf ("off_btnw.picc=0");
id(disp1).send_command_printf ("man_btnw.picc=0");
id(disp1).send_command_printf ("auto_btnw.picc=1");
- if:
condition:
- lambda: |-
return (strcmp( id(boil_mode).state.c_str(), "Local") == 0);
then:
lambda: |-
id(disp1).send_command_printf ("off_btnw.picc=0");
id(disp1).send_command_printf ("man_btnw.picc=0");
id(disp1).send_command_printf ("auto_btnw.picc=2");
HA config
# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:
logger:
default: info
# Text to speech
tts:
- platform: google_translate
group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
# Example configuration.yaml entry
sensor:
- platform: systemmonitor
resources:
- type: processor_use
- type: disk_use_percent
arg: "/"
- type: disk_free
arg: "/"
- type: memory_use_percent
- type: network_in
arg: eth0
- type: throughput_network_in
arg: eth0
- type: network_out
arg: eth0
- type: throughput_network_out
arg: eth0
- type: processor_temperature
- type: last_boot
- platform: time_date
display_options:
- 'time'
- 'date'
- 'date_time'
- 'date_time_utc'
- 'date_time_iso'
- 'time_date'
- 'time_utc'
- 'beat'
# OPTIONAL CPU Raspberry Pi Temp
- platform: command_line
name: CPU Temp
command: "cat /sys/class/thermal/thermal_zone0/temp"
unit_of_measurement: "°C"
value_template: '{{ value | multiply(0.001) | round(2) }}'
- platform: mqtt
name: "Temperature Test"
unique_id: 'tempTestEnt'
state_topic: "pi/sensor1"
unit_of_measurement: "°C"
value_template: "{{ value_json.temperature }}"
- platform: template
sensors:
thermostat_status:
friendly_name: 'HVAC Status'
unique_id: 'sensor.hstatus'
value_template: "{{ states.climate.office_trv.attributes.system_mode }}"
test_txt_sensor:
friendly_name: 'Test Text'
unique_id: 'sensor.bschet'
value_template: 'Hello Test'
schedule_5268b9:
friendly_name: 'Boiler Schedule'
unique_id: 'sensor.bsched'
value_template: '{{ states.switch.schedule_5268b9.attributes.next_trigger }}'
switch:
- platform: mqtt
unique_id: pi_test_switch
name: "Switch Test"
state_topic: "pi/switch1/stat"
value_template: "{{ value_json.status }}"
command_topic: "pi/switch1/cmmd"
payload_on: '{"status": "on"}'
payload_off: '{"status": "off"}'
state_on: 'on'
state_off: 'off'
optimistic: false
qos: 0
retain: false
Link to the logs as they are to big for the board
Logs
Thank you for help
I will setup a new device today with minimal code to see if its device code based or it is server side
Cheers
Paul