Open Bedroom Thermometer: Integration with the thermostat

My main goal of setting an extra thermometer in the bedroom was to integrate it with my open thermostat, placed in the living room. My house is not big, but when we go to bed, we are not in the living room anymore. We want it to watch for the temperature in our bedroom.

Of course, I wanted to automatize this switch as well. Every night, when we go to sleep, the thermostat switches the tracking of the temperatures from the living room thermometer, to the bedroom thermometer. When we wake up, it switches back to the living room thermometer, the one in the thermostat.

One of the great things about using open hardware and software is that you can customize everything. I could change and adapt both the UI and the logic of the thermostat to incorporate the new temperature readings

UI integration

HestiaPi UI is just Javascript (Vue.js) and HTML, running on Kweb, a very light browser for Raspberry Pi. I redesigned the interface to accommodate the new figures. I also added the buttons to switch manually the thermometer that drives the thermostat behavior, from the thermostat sensor to the bedroom thermometer and back. HestiaPi UI communicates over MQTT, the same way than ANAVI Thermometer, so it was pretty straightforward to copy the same logic.

You can find the code in the anavi-thermometer branch of my fork of hestia-touch-one-ui.

Modified interface of HestiaPi including ANAVI Thermometer readings

Backend integration

HestiaPi logic is built on top on OpenHAB. Despite OpenHAB is a bit heavy for running in a Raspberry Pi Zero, it provides HestiaPi with all the power of smart home capabilities.

Backend integration involves new OpenHAB things, channels, items and rules, so it deserves its own post: ANAVI Thermometer – HestiaPi integration

ANAVI Thermometer things and channels in Hestia Pi’s OpenHAB

I feel grateful for having found these two great open projects and being able to play with them, learn many things and having a feeling of accomplishment after customizing my own setup!

This is the last post on these ANAVI Thermometer series, but not the last from Hestia Pi… More hacking to come!

Debugging in Kweb

I have been recently hacking on HestiaPi‘s interface, so I could add the measures from ANAVI Thermometer to HestiaPi‘s interface. When I first tried to deploy the last version of the interface, it didn’t work

It looked like a Javascript error, so I tried to see what was going on in Kweb, the browser that runs hestia-touch-one-ui, HestiaPi‘s interface. Kweb is a minimal kiosk browser. It is perfect for RaspberryPi, where resources are limited (HestiaPi runs in a RaspberriPi Zero)

I could open a new console exporting the X window system ssh -Y hestiapi, and fire up Kweb. However, Kweb interface does not comes with a Javascript console like the ones web developers are used to

But I could use a trick to find out what it was going on. I added a callback to window.onerror event so I could show the errors through alert

<script>window.onerror = function(msg, url, lineNo, columnNo, error) { alert(msg); alert(url); alert(lineNo); alert(columnNo); alert(error); }</script>

It was quite tricky but it did the job. I could find out that the building process was not traspiling ES6 let, happily fix the issue and deploy my bright new with bedroom measures from ANAVI Thermometer in HestiaPi!