Boiler Monitor, Display and Home Assistant Project #20429
richardsg307
started this conversation in
Show and tell
Replies: 1 comment 2 replies
-
Did you consider whether the recently added HASPmota |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Background
For a couple of years now, I've had an ESP8266 on my boiler monitoring temperatures and whether it's burning or not and reporting to Home Assistant. Recently, I got a couple of Lilygo T-Display-S3 ESP32s to mess around with and thought it would be good to have the display as my boiler monitor. After giving it some thought and some successes with Tasmota, Berry, LVGL and HASPmota, I gave it a go. Those last three things were all new to me and I found little on the web to guide me (I like following examples rather than reading often cryptic manuals), but with the help of this forum and in particular
sfromis
ands-hadinger
, I got there in the end. So here is my Project with all the code and stuff and I hope others find it helpful. I've got a few ideas to tweek it a bit but now it's in, I want to let it settle down and prove it's working properly over several days. I'll probably spend a few days writing this project so it will grow as I add more detail; I hope that's OK.Overview
First off, some pictures of the display.
The device has sensors monitoring 3 temperatures and 2 opto-isolated mains detectors for incoming demand (HW/CH) and if the internal thermostat is also demanding. From the latter I can derive burn time and how much oil is being consumed and even get how much oil is left in my tank. It reports to Home Assistant and gets some data back , eg the kwh and cost for the day (I intend to add 'Oil in tank').
On the Tasmota side, there is some setting up to do, some Berry code to add and a HASPmota page file that defines how things get displayed on the screen.
In Home Assistant, it gets picked up as a Device and a couple of MQTT sensors need adding manually through the configuration.yaml file. There are also a few Automations and Template entities to add. I will describe all these in the sections below.
Hardware
Lilygo T-Display-S3 and Shell - Bangood
Mains detector (3 Channel) - AliExpress
Temperature Sensors DS18B20 - AliExpress
Tasmota
SetOption114 1
andSetOption73 1
are required along withSwitchMode1 2
andSwitchMode2 2
.Button1
andButton2
. Both are used in the code/Home Assistant.Configure Other
I set both theDevice Name
andFriendly Name 1
toBoiler
.Configure MQTT
I set my Home Assistant IP inHost
, entered my User and Password, and set theTopic
toboilerdisplay
.Berry
This is where things got tricky for me with no knowledge of Berry. What I've done may be 'bad' code but it works. I'm happy to receive constructive criticism. The first thing to note is that Berry is only on the ESP32 Tasmota variants and my understanding is that it is an object language sitting alongside Tasmota and can communicate with it. When Tasmota starts up it looks for a file called
autoexec.be
and will execute it. In that file you can create functions, rules and timers (and more I expect but they are all I used). Here is my Berry code in theautoexec.be
file:There's lots of comments in the code so I won't try to explain it here but will try to answer any questions on it.
Another file called
lv_boiler_graph.be
is responsible for the graph page shown in one of the pictures above. I based it on the code I found in this GitHub Tasmota repository for the WiFi widget included on the Tasmota page. This is the code for mylv_boiler_graph
widget:I've added comments to my code and don't profess to understand much of the LVGL speak within it.
These two files above and a third file ( haspmota_widgets.tapp ) got from GitHub need adding to the device through the
Manage File System
console.HASPmota
This is where you define the Pages you want displayed on the screen. It looks a bit daunting at first but you quickly get used to it once using it, I found. Each line of the
pages.jsonl
HASPmota file represents 1 object on screen. The line contains the attribute values you want for each and if omitted they take a default. Here's my file which also needs adding through theManage File System
console:Persist
I wanted my device to be the 'Source' of the lifetime usage in hours of the boiler so needed to ensure it retained it across reboots. That it where Persist comes in; it's a method to store something in Flash memory. I read that it wears out over so many writes but without knowing the numbers (I read anything between 10,000 and 100,000 write cycles) didn't want to push my luck so opted to save the number once per day at midnight using the
mn()
function and thecron
in theautoexec.be
file.I can't remember the details but I think I created the original Persist entry using the Berry Console by typing something like:
You have to type 2 Returns together to get the above 3 lines to then run. After that you will see a new file called
_persist.json
in theManage File System
; mine now looks like:If people think I could get away with more frequent saving then let me know. Currently, I'm not planning on rebooting that often so the odd day's missed hours don't worry me.
Wiring
Here's the wiring diagram:
And a picture of my original loom. Originally I was going to have the plug/socket connector inside the case but I decided to make the wiring to the board longer and the connector outside the casing for ease of taking it back to the breadboard.
Home Assistant
If the Tasmota Integration is installed in HA the device should be discovered automatically and go by the name of the Device Name given in
Configuration Other
, in my caseboiler
. The mains detection Entities will have the namesbinary_sensor.boiler_switch1
and_switch2
. The Temperature sensor Entities will have the names of the formsensor.boiler_ds18b20_1_temperature
also a 2 and a 3. Now in my case the device appeared twice, with the Temperatures in one and the mains detectors in the other. It may have been because I'd been messing around on the workbench with 2 different Lilygos using the same MQTT Topic and HA just got in a muddle. Hopefully, anyone implementing this project does not get the same!Two other Entities (runtime and life runtime) coming from the device have to be manually entered in the configuration.yaml file with the following code:
You should note that the Topics above match the Topics used in the Berry
autoexec.be
code file. The Entities will go by the namessensor.boiler_runtime_today
and_life
. If you already have mqtt sensors configured, miss out the first 2 lines and add the rest to your mqtt block.That's all the sensors sorted and you now need to add an Automation to publish the HA stats. I chose to do this every 5 minutes, when there's a change in
sensor.boiler_runtime_today
and in response to the second onboard button being pressed. Here is the code for the automation:Note:
discovery_id:
anddevice_id:
will be different on another implementation. The mqtt publish topic issues the commandBoilerStats
to the Tasmota device and theboilerstats
function defined in theautoexec.be
file is what gets run as a result.Also note that I was concerned about reboots of the device during the day losing the runtime so far, so I added some code to retain the value so far in HA, report it in the boiler stats such that the device can compare the 2 values and update its internal one if necessary. The code is in the
autoexec.be
above and the HA automation is here:That's all for now. I have some other stuff in HA to record the oil left in the tank as it gets used and to store values for 'Yesterday' so I can have dashboards that show Today's values with Yesterday's as a comparison. I also want to add some other features. Once I've tidied them up to my liking I will add them.
Happy to have comments about how I might have done stuff better and questions if I've not explained anything properly.
Beta Was this translation helpful? Give feedback.
All reactions