01 March 2014

openHAB heats my living room when I need it

After I started my smart house project I've had so many ideas about what to fix and what to make, but the most important thing when I started was to make my living room comfier during the norwegian winters. So, after installing my Raspberry PI, my Razberry card and configuring my openHAB to start working I connected my two Fibaro wall plugs.

The advantage with these wall plugs are that they are quite small compared to other such wall plugs, and they can tell me how must energy the connected appliance is using. I'll take advantage of this feature later, as I don't have any temperature sensor just yet.

I've connected one wall plug to my electric radiator. This radiator remembers the temperature between each time it is switched off and on. The other wall plug is connected to my 2000 watt fan oven which I use to quickly heat the living room.

Before writing this, I've put all my openHAB configuration on GitHub, check it out here

So, there's some small challenges:

  1. How to switch heating of when the living room has reached my desired temperature?
  2. How can openHAB know when to switch heating on?

Configure the ovens in openHAB to read consumed energy
My two ovens are defined as number-items shown below. This is so that I can read the value in my rules, I'll come back to this.

/* Energy measuring */
Number power_fanoven "Energy fan oven	[%.1f W]"  (Energy) {zwave="2:command=sensor_multilevel"}
Number power_radiator "Energy radiator	[%.1f W]"  (Energy) {zwave="3:command=sensor_multilevel"}

Then I've registered the same two plugs as items/switches so that I can easily switch them on or off:

/* Heating */<br />
Switch switch_radiator    "Radiator"             (Heating){zwave="3:command=switch_binary"}<br />
Switch switch_fanoven    "Fan oven"             (Heating){zwave="2:command=switch_binary"}<br />

To be able to heat my living room in a "smart" way I'll have to make some rules reading and using the number-values defined above. But first I do want to show how much total energy these ovens are using at this moment, this is from my sitemap-file:

Frame {
  Group item=Energy

Now I can both see the consumed energy and I can switch my heaters on or off (don't worry about the presence switch just yet, there will be a blog post about it later)

smarthouse openhab

Then I'll have to make some rules to get this working for me, I want the living room to be warm when I get up in the morning:

rule "Heat the living room"
		Time cron "0 30 5 ? * MON-FRI"
		sendCommand(Heating, ON)
		pushNotification("Varme","Varming av stua har startet")

The rule says simply: Switch on all items in the "Heating" group at 5:30 every week day. And the send a push notification to let the user know it is switched on.
So, in the weekends I do the same, but I want it to be switched on a bit later in the morning.
Next thing is to make sure the heating is being switched off at a certain time:
rule "Switch of heating during the week"
		Time cron "0 0 7 ? * MON-FRI"
		if (switch_radiator.state == ON || switch_fanoven.state == ON) {
			sendCommand(Heating, OFF)
			pushNotification("Heating","Heating stopped at: " + Date.state.toString())
This is nice, but I don't want my living room too hot either, so I want the ovens to be switched of at a given temperature. At the moment I'll use the built in thermostat in the electric radiator and my energy measuring to check if I should switch the heating off.
I know that the electric radiator uses less than 10W when the temperature in the room has reached its preprogrammed oven temp, currently 21 degrees celsius.
So, this is the rule to fix that:
rule "Switch of heating if temp for radiator is ok"
		Time cron "0 0/5 * * * ?"
		var double t = new Double(power_radiator.state.toString())
		if (switch_fanoven.state == ON &amp;&amp; t &lt; 10) {
			sendCommand(Heating, OFF)
			pushNotification("Heating","The living room heating is finished")
What I do is I check the energy consumption of my radiator every 5 minutes. If it is lower than 10 watt, I switch off all heating.

These rules and items is the start of making my living room more comfortable in the winter. So do you have any suggestions on how I can improve it?
Some examples are:
- Leave the raditor on for the time I'm home, and then start or stop the fan oven based on the power consumption of the radiator. This
will make it possible to keep a steady temp during the day when I'm home.
- Check if I'm home or not (more on that later)