IoT Clock Tower Automation Project

The Challenge of Pendulum Clocks

Pendulum clocks are beautiful and historically significant, but they can be quite tricky to maintain. Changes in temperature, humidity, and even air pressure can affect the pendulum’s length, making the clock run too fast or too slow. This means you have to adjust the pendulum frequently to keep the clock accurate, which can be a hassle.

Our Solution

To tackle this problem, my dad and I decided to automate a historic clock tower located in Oostwoud, a small village in the Netherlands, situated in the province of North Holland. Our idea was to have the pendulum run a little fast all the time, then catch it and correct it before it got too far ahead. By doing this, we could ensure the clock stayed accurate without needing constant manual adjustments.

Hardware Used

For the hardware, we used a Raspberry Pi and some custom components to control relays and read data from industrial inductive sensors. The Raspberry Pi acted as the brain of our system, running the control logic and communicating with the sensors and relays.

Software and Automation

We used Home Assistant to handle the automation tasks. Home Assistant is an open-source platform that helps control and automate smart devices. By integrating our custom hardware with Home Assistant, we created a dashboard to monitor and control the clock tower.

Python Script and MQTT

To interface with the hardware, we wrote a Python script that ran on the Raspberry Pi. This script was responsible for reading data from the sensors and controlling the relays. The measurements from the sensors were then converted into MQTT (Message Queuing Telemetry Transport) messages. MQTT is a lightweight messaging protocol ideal for IoT applications, allowing us to easily send the sensor data to Home Assistant for processing and display.

Here’s a screenshot of our Home Assistant dashboard:

The dashboard gave us real-time information on the clock’s performance, including pendulum speed, clock accuracy, and the environmental conditions affecting the clock. This setup allowed us to make adjustments and monitor the clock remotely, keeping it accurate no matter what.

Conclusion

This project was a great learning experience for both me and my dad. By combining traditional clock mechanics with modern IoT technology, we managed to preserve the clock’s historical value while ensuring its accuracy and reliability. It’s a perfect example of how IoT can be used to solve real-world problems.

Connected Vaillant to Home Assistant

Introduction

I bought a new Vaillant ( Hr-ketel ecoTEC plus) central heating boiler a few months back, my old boiler from 2001 still worked, but I rather had it replaced, before it broke. When ordering there was an option to make it connected with the vSMART for about €200 extra. It sounded a bit to much and saw no integration with Home Assistant (HA) directly (at that time). So I tried an alternate way.

eBUS

Vaillant uses a protocol called eBUS for external communication. This protocol is based on UART but at different voltage levels, so be able to use this protocol we need some hardware to do the translation. Although there were some solutions available online, I couldn’t find a tiny and SMD variant. This is why I decided to create my own PCB in KiCAD. My design is based on the following project: https://ebus.github.io/adapter/. My project can be found here: https://gitlab.com/fromeijn/ebuzzz-adapter

This PCB uses a USB to UART converter board with an CP2102, e.g this one. It is electrically isolated so no harmful ground loops or other issues can occur. There are also some helpfull LEDs to show you what is going on.

Home Assistant Integration

To integrate with Home Assistant I used ebusd running on an Raspberry Pi I had laying around. The ebusd has an MQTT client integrated, this is an easy way to hook it up to Home Assistant. To give you an idea how it is hooked up see this drawing below. The eBUS to USB converter board will be connected to the bus with two wires. The position of those wires doesn’t matter.

To install ebusd on Raspberry Pi OS (Raspbian) you use the following documentation from the ebusd repository: https://github.com/john30/ebusd/wiki/1.-Build-and-install

I used it in the following configuration for ebusd, there are some optional parts.

# add custom config for the VRT350 thermostat (only needed if you have VRT350)
cd /home/pi/
git clone https://github.com/john30/ebusd-configuration.git
cd ebusd-configuration/
cp ebusd-2.1.x/en/vaillant/15.370.csv ebusd-2.1.x/en/vaillant/15.350.csv

# you can change the r; at the beginning of the lines by r1; so it will be read out automatically and pushed on MQTT. If you can also poll values via MQTT, see down below for an example.

Edit /etc/default/ebusd

# Without local ebusd-configuration
EBUSD_OPTS="--scanconfig 
--mqtthost=<homeassistant_ip> --mqttport=1883 --mqttuser=<user> --mqttpass=<passwd>"

# With local ebusd-configuration
EBUSD_OPTS="--scanconfig 
--configpath=/home/pi/ebusd-configuration/ebusd-2.1.x/en --mqtthost=<homeassistant_ip> --mqttport=1883 --mqttuser=<user> --mqttpass=<passwd>"

To restart the ebusd

sudo service ebusd restart

In Home Assistant you need to have a MQTT broker setup. In my case I use Mosquitto broker addon, what can be install via the Supervisor. See the documentation of the addon. Also do not forget to add the MQTT integration into your config. I used the MQTT HVAC integration and set is up as follows:

mqtt:
  broker: core-mosquitto
  username: <your-mqtt-user>
  password: <your-mqtt-pass>
  discovery: true

climate:
  - platform: mqtt
    name: CV
    max_temp: 25
    min_temp: 15
    precision: 0.1
    temp_step: 0.5
    modes:
     - auto
     - heat
     - cool
     - 'off'
    mode_state_template: >-
      {% set values = { 'auto':'auto', 'on':'heat',  'night':'cool', 'summer':'off'} %}
      {{ values[value] if value in values.keys() else 'off' }}
    mode_state_topic:  "ebusd/350/Hc1OPMode"
    mode_command_template: >-
      {% set values = { 'auto':'auto', 'heat':'on',  'cool':'night', 'off':'summer'} %}
      {{ values[value] if value in values.keys() else 'auto' }}
    mode_command_topic: "ebusd/350/Hc1OPMode/set"
    temperature_state_topic: "ebusd/350/DisplayedHc1RoomTempDesired"
    temperature_low_state_topic: "ebusd/350/Hc1NightTemp"
    temperature_high_state_topic: "ebusd/350/Hc1DayTemp"
    temperature_low_command_topic: "ebusd/350/Hc1NightTemp/set"
    temperature_high_command_topic: "ebusd/350/Hc1DayTemp/set"
    current_temperature_topic: "ebusd/350/DisplayedRoomTemp"

Tip: Use MQTT Explorer if you are having problems getting MQTT to work between HA and ebusd.

Automations

When having home assistant and ebusd connected we can start automating things and let the computer do stuff for us. I have configured a google calendar in which I can plan my normal heating schedule. But this only is enabled when i’m home, and turns off when I leave the house.

Heater on/off on calendar automation

alias: Heater on/off on calendar
description: ''
trigger:
  - entity_id: calendar.heater
    platform: state
  - entity_id: binary_sensor.people_home
    platform: state
    to: 'on'
condition:
  - condition: state
    entity_id: binary_sensor.people_home
    state: 'on'
  - condition: template
    value_template: '{{ not is_state("climate.heater", "off") }}'
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: calendar.heater
            state: 'on'
        sequence:
          - service: climate.set_hvac_mode
            data:
              hvac_mode: heat
            entity_id: climate.heater
    default:
      - service: climate.set_hvac_mode
        data:
          hvac_mode: cool
        entity_id: climate.heater
mode: single

Heater low when nobody home automation

alias: Heater low when nobody home
description: ''
trigger:
  - entity_id: binary_sensor.people_home
    from: 'on'
    platform: state
    to: 'off'
    for: '00:05:00'
condition: []
action:
  - data:
      hvac_mode: cool
    entity_id: climate.heater
    service: climate.set_hvac_mode
mode: single

Poll WaterPressure from bai over ebus

alias: Poll WaterPressure from bai over ebus
description: ''
trigger:
  - platform: time_pattern
    minutes: /1
condition: []
action:
  - service: mqtt.publish
    data:
      topic: ebusd/bai/WaterPressure/get
mode: single

we also want a sensor to receive this data, add this to your configuration.yaml

sensor:
  - platform: mqtt
    name: "Water Pressure CV"
    state_topic: "ebusd/bai/WaterPressure"
    unit_of_measurement: 'bar'
    value_template: "{{ value.split(';')[0] }}"

Conclusion

With this integration we can control the temperature remotely or automatically. I’ve added presence detection and a google calendar so no energy is wasted which is a big plus for me. This project was fun to get my home automation kick stared and I learned something one the way. Hope this helps some of you as well!

Boards (un)available

Unfortunately I have decided to stop my production of these board. If you want to build your own see https://gitlab.com/fromeijn/ebuzzz-adapter

Motorized IKEA lamp

Today I want to share with you that I fitted a motor in this IKEA lamp. It is now possible to open and close the lamp without touching it. Automating would be my next step, so it can be controlled from everywhere, stay tuned!