Monday, 20 April 2015

Z-wave Immersion Heater Project – Home Automation with Vera

I thought I’d write about my latest Z-wave Home Automation project, to be able to control the immersion hot water heater with Z-wave / Vera. The reason for needing to do this is because our gas central heating system is very old and currently we are unable to have water only turned on with the gas. So in the summer months we rely on the electric immersion heater, which I often turn on and then forget about and I have been known to leave it switched on for days, which isn’t good! Ideally I need to invest in getting the boiler and plumbing sorted out, but in the mean time this project is really going to help.

Once the immersion heater can be controlled via a Fibaro 3KW relay module, I can then schedule some scenes in Vera to automatically turn on the immersion heater at 6am for twenty minutes, so we have hot water when getting up.

Here you can see my new Immersion Heater device in Vera UI5.

image

My initial plan was just to wire in the Fibaro 3KW relay insert module in behind the immersion heater switch in the kitchen.

image

However my concern was that the immersion heater uses around 3KW and that the Fibaro relay module would be operating at its upper limits, so a safer and smarter solution was needed. I then thought about also using an additional more heavy duty relay and to have that one handle the heavy load and just have the Fibaro relay switch on and off the additional rely.

So I spoke to my new electrician friend Ahmer Mohammad, who is also a home automation enthusiast (his website "A Smarter Home"), and he also sells and installs Solar Thermal (hot water heating) systems via his renewables company "Solar Sparks", which is based in Leeds, West Yorkshire, England. 

With his advice and installation instructions I was able to purchase a suitable relay and install everything and get it all up and running. I’d also like to thank user “RexBeckett” on the Micasaverde Vera user forums, who is one of the well known experts on there, for his input and advice on the project also!

DISCLAIMER ALWAYS SEEK PROFESSIONAL ADVICE FROM A CERTIFIED ELECTRICIAN FOR YOUR OWN INSTALLATIONS

Here is the wiring diagram I was working from, which was approved by the Electrician:

image

Here is a photo of the SSR and information about the terminals:

image

And here are the written instructions from the Electrician:

Use a junction box or heavy duty 20A connectors for the 'lives' as only 1 is coming out of the switch but you need to connect to 3 places.
same with neutrals as only 1 from switch but you need to connect to 3 places as well.
Live from switch connects to:
live in Fibaro
IN in Fibaro
on 1 of the output terminal in the relay
Neutral from switch connects to:
neutral of Fibaro
neutral of the relay (INPUT SIDE)
neutral of the immersion
OUtput 1 of the Fibaro connects to the Live of the relay INPUT side
Live of immersion connects to the switched out terminal of the relay
principle
turn switch on this acts as our isolator for this whole system so don’t need to turn mains off if ever need to change or alter Fibaro, relay or immersion
Fibaro becomes live and ready to accept z-wave commands
Fibaro will then turn the relay on or off
the output contacts of the relay will close or open respectively
when relay contacts closed the immersion is on
nice and safe as we previously discussed.


Parts I needed for the job:

1 x Fibaro 1* 3KW relay insert module (Note- these are now discontinued and have been replaced with the newer 1* 2.5KW FIBEFGS-212)

image

You can purchase Z-wave Euro devices from us directly, contact us to discuss your personal requirements and we can then offer bespoke discounted pricing.

1 x Solid State Relay which I purchased off eBay. You can buy these without the heat sink, I bought one that came with the heat sink.

Single Phase Solid State Relay SSR-40AA 40A 150-350V 24-480VAC w Heat Sink



Here is the specification of the SSR

Product Name
Solid State Relay + Heat Sink
  • Model
    SSR-40AA
  • Material
    Metal, Aluminum, Plastic
  • Rated Load Current
    40A
  • Input
    AC 150-350V
  • Output
    AC 24-480V
  • Total Size (Approx.)
    8 x 5 x 8cm / 3.1" x 1.9" x 3.1" (L * W * H )
  • Color
    Black
  • Weight
    190g
  • Package Content
  • 1 x Solid State Relay
  • 1 x Heat Sink
1 x Double Pole Switched Fused Spur, to replace the 1970’s looking switch that was in my airing cupboard, where the hot water cylinder tank is located.

image

This is the old switch in the airing cupboard I replaced and don’t ask me why the walls in the airing cupboard are pink? I didn't paint them that colour!

image

1 x Single Dry lining box 35mm bought from Screwfix here.

image

1x Electrical enclosure box 180 x 110 x 100mm from Screwfix here.

IP55 Enclosure Grey 180 x 110 x 100mm

1 x 20A Junction Box also from Screwfix here.

image

I also needed some twin and earth socket wire.

Installation:

First step was to ensure that the switch for the immersion heater in the kitchen was turned off, to isolate the circuit upstairs in the airing cupboard. Then I started to remove the existing ON/OFF switch in the airing cupboard, that connects to the immersion heater at the top of the water tank via a flex cable.

image

I then knocked out a new hole in the wall for the new dry lining box. The cable you can see is the existing cable that comes from the immersion heater wall switch downstairs in the kitchen.

image

Here is the back of the switched fuse spur, I connected the existing cable in the wall to the Live and Neutral IN and the earth cable to one of the earth connectors.

image

image

image

I then added a short piece of new twin and earth cable to the Switched Fused Spur – To the Live and Neutral OUT and earth to the other earth connector. This cable will be fed back through the dry lining box and connected to the new 20A junction box that will be placed and hidden inside the stud wall.

image

image

Feeding the new cable back through the dry lining box.

image

Attaching the new cable to the Junction Box. Live, Neutral and Earth, the various connections needed as shown in the wiring diagram, will all come from this new junction box.

image

I then starting checking out the enclosure box, to see where it would be mounted on the wall and where I needed new holes in the wall for the cables to come through in to the box

image

image

My Dad always told me make sure its level!

image

I made two new holes in the wall behind where the enclosure box will be mounted.

image

I also cut out all the access holes of the box for air flow, as I was worried about how hot the SSR relay would get? The heat sink does get hot and you can’t leave your finger on it for too long!

image

In this picture you can see I have added two new pieces of twin and earth cable and looped them round in the two new holes and out through the larger hole for the dry lining box.

image

Next step was to connect the ends to the Junction Box.

image

image

As per the wiring diagram, I also needed one extra Live cable, so I also added a single Live cable from the junction box and  looped it round to one of the holes in the wall, to go in to the enclosure box. I also at this point, wired in the neutral and earth cables from the immersion heaters flex cable in to the junction box, I don’t have photos of this step.

In this photo I have put the top on the junction box.

image

Next I mounted the SSR relay in to the box, I had to drill two small holes in to the base of the box and using some nuts and bolts secured the SSR in to the box.

image

I then cut the excess off the bolts with a hack saw.

image

I then pushed the junction box in to the larger hole to hide it in the stud wall and started to connect up some of the cables to the SSR relay.

At this point you really need to start following the wiring diagram, to work out which cables are connecting to where on the SSR and to the Fibaro relay unit.

image

image

I mounted the SSR upside down, which just seemed easier as far as the wiring was concerned.

image

Once I had completed all the wiring and triple checked everything, I turned back on the power and tested I was getting power to the various live cables with my little screw driver that lights up.

image

It was then time to add the new Fibaro 3KW relay to Vera. So I put the VeraLite in battery mode, pressed the plus button and then pressed the button on the Fibaro module three times.

image

Here is a picture of the SSR powered up the red light comes on.

image

Here is the completed installation, minus a bit of pink paint as I had to fill in and tidy up the wall around the fused spur.

image

In the Vera web UI I could then see two new _Appliance Modules devices has been added. One is a child device and the other is the father or main device.

image

The reason you get two new devices, even though its only a 1* 3KW relay is because:

“The child device is for the S2 input. It allows you to use it as an extra input which can be useful if you need some way to signal Vera with some state.
The S1 input would switch the output and thus control the SSR directly.”


As the child device isn’t needed in my setup I hid the device using the following method:

You can hide it using the command:

luup.attr_set("invisible","1",123)

Replacing 123 with the device number. In UI5, this needs to be placed in Startup Lua. In UI7, it apparently sticks if run once in Test Luup code (Lua).

image

Thanks to RexBeckett for this information and solution.

Immersion Heater turned ON

image

House Power Usage when the immersion is turned ON.
(CurrentCost EnviR Energy Monitor integrated into Vera with the plug-in).

image

After installing everything and actually sitting down and using Vera to turn on the Immersion Heater and then watching the real time power consumption usage, I noticed something that looked odd.
I thought there might be a problem? After about 8 minutes of turning on the Immersion the wattage dropped from 3000 and something watts to 600 watts. I went upstairs to the box and the SSR was still lit up and powered on. Then several minutes later it had shot back up to 3441 watts. It would keep doing this as if the immersion heater was being turned on and off after so many minutes. I suspected that it must be a thermostat on the hot water tank but wasn’t sure. Both the electrician and our resident forum expert both confirmed it was likely due to the thermostat on the immersion itself inside at the top of the tank.

Here’s what RexBeckett said about it:

“Immersion heaters usually have built-in thermostats. These turn on and off to keep the water temperature fairly constant. Because they are physically close to the heater, they can cycle quite often even though the tank temperature does not change quickly. I would expect your energy monitor to show the change in energy use as the 'stat cycles.”

After leaving the Immersion turned on for twenty minutes or so I checked the water from the tap and it was nice and hot, so it was indeed all working perfectly fine!

Summary

I am very pleased with how this project turned out and I will now be able to schedule some scenes in Vera to automatically turn on and off the Immersion Heater early in the morning so the water  is nice and hot for when we get up. We can now also turn on and off the Immersion heater using our mobile phones and tablets, even when outside of the house!

Here are a couple of screen shots of the new Immersion Heater device in the Vera mobile app Authomation HD.

image

image

Next and probably a more expensive job, find a plumber to sort out the central heating boiler properly.


KodiRemote for Micasaverde Vera Home Automation - Part 2

In part one here I discussed the installation and setup for the newer project called KodiRemote for integrating Kodi Media Center and the Micasaverde Vera Z-wave controller. This is based on the older project XBMCState.
In part two I will look at creating some scenes in Vera and using the playback status updates sent from Kodi to Vera to automate some lighting and curtain control. In Vera I created three new scenes.
  • Kodi – Close Curtains
  • Kodi – Lounge Dim 25%
  • Kodi – Lounge On
image

Scene – “Kodi – Lounge Dim 25%”

On the Triggers tab of this scene I created four new triggers. I named them as follows:
  • Kodi – Video Resumed
  • Kodi – Video Starting
  • Kodi – Music Starting
  • Kodi – Music Resuming
image

So if any of these triggers are detected the lights will be dimmed down to 25%.

If we look at one of the triggers we can see in more detail how it works.

Under the “Device” field you select the KodiRemote device instance you would like to configure. As these scenes are for the Kodi HTPC in my Living Room I selected the #113 “Kodi01 – KodiRemote” device from the device list.

In the “What type of event is the trigger?” Select “Player State Changes”.

In the “Name for this trigger” field give the trigger a suitable name, in this example I called it “Kodi – Video Resumed”.

In the “Player State” field you select the playback state of Kodi, in this example I selected “Video is resumed”.

This means that when Video is resumed on the Kodi Media Center PC, this Vera scene with this trigger will then perform some action.

image

Here is another screen shot of the “Kodi – Music Starting” trigger.

image

So once you have created all your triggers we then need to complete the scene creation by adding our actions that Vera will carry out.

In my case I have some LUUP code that should be run when either one of the four triggers are detected.

image

I have also created a Virtual Switch in Vera using the Virtual Switch plug-in from the MiOS Marketplace here.

I named the Virtual Switch “Link Kodi to Devices?”
image

If the Virtual Switch is turned ON then Kodi Media Center is linked to the three scenes.
  • Kodi – Close Curtains
  • Kodi – Lounge Dim 25%
  • Kodi – Lounge On
If the Virtual Switch is turned OFF then Kodi Media Center is not linked to the three scenes and the automation of dimming or brightening the living room lights or automatically closing the curtains, will not happen.

E.G. By using a Virtual Switch such as this one, you can turn on and off the integration between Kodi and Vera which is very useful, as you might not want it to happen all the time.
image

In the name field enter a suitable name for the Virtual Switch.

image

In the Text1 field I entered the text “Linked = ON”.

You also need to make a note of the Virtual Switches device ID number in Vera? As we will use this in our scenes LUUP code.

image

Here is the Luup code from my “Kodi – Lounge Dim 25%” scene.

Basically it does the following:

1. Checks first to get the current status of the Virtual Switch with the device ID number 92. Is it on or off? 1 is ON 0 is OFF.

2. If that Virtual Switch device is currently turned ON then..

3. Run another scene to dim the lights 25%, in this case it runs my scene number 5 which is just a regular scene that dims the lights to 25%.

4. If the Virtual Switch was turned OFF then it would just end and not do anything.
   1: Link_XBMC_to_devices = luup.variable_get("urn:upnp-org:serviceId:VSwitch1","Status",92)

   2: if(Link_XBMC_to_devices=="1")then

   3: luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1","RunScene",{SceneNum="5"},0)

   4: end
Here is the “Kodi – Lounge On” scene triggers.
  • Kodi – Video Paused
  • Kodi – Music Stopped
  • Kodi – Music Paused
  • Kodi – Video Ended
  • Kodi – Video Stopped
image

So if any of these triggers are detected then the LUUP code in the “Kodi Lounge On” scene will be run.

image

1. Checks first to get the current status of the Virtual Switch with the device ID number 92. Is it on or off? 1 is ON 0 is OFF.

2. If that Virtual Switch device is currently turned ON then..

3. Run another scene to turn on the Lounge lights, in this case it runs my scene number 1 which is just a regular scene that turns on the lounge lights to 100%.

4. If the Virtual Switch was turned OFF then it would just end and not do anything.

   1: Link_XBMC_to_devices = luup.variable_get("urn:upnp-org:serviceId:VSwitch1","Status",92)

   2: if(Link_XBMC_to_devices=="1")then

   3: luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1","RunScene",{SceneNum="1"},0)

   4: end
So with these two scenes and the triggers that have been added to each and if the Virtual Switch is turned ON, then for example if I start playback of a movie in Kodi Media Center, the lounge lights will automatically dim down to 25%. And if I then pause or stop video playback the lounge lights will automatically brighten up to 100%.

Obviously we only want this to take place when its actually night time, this is where the Day or Night plug-in for Vera we installed in Part one comes in to play.

In the KodiRemote (Micasaverde Kodi Event) add-on for Kodi in the settings there, we need to specify that the various playback states are set to “Night”.

image

[image%255B152%255D.png]

And finally I have a third scene in Vera for my Z-wave curtain rail.

I only have one trigger in this scene and that is “Kodi – Video Starting”.

Basically this scene closes the curtains if it is currently night? and if the curtains are still open? and if I start to play video in Kodi Media Center, then the curtains will be automatically closed.

image

Here is the LUUP code for the “Kodi – Close Curtains” scene.

image

1. Checks first to get the current status of the Virtual Switch with the device ID number 92. Is it on or off? 1 is ON 0 is OFF.

2. If that Virtual Switch device is currently turned OFF then just end and do nothing.

3. Checks to see if the curtains are currently opened or not? Device ID #107 is the device ID number in Vera for my Fibaro Blind Controller module.

4. If the curtains are open (which is 100) then..

5. Run another scene to close the curtains, in this case it runs my scene number 138, which is just a regular scene that closes the curtains.

6. End.
   1: Link_XBMC_to_devices = luup.variable_get("urn:upnp-org:serviceId:VSwitch1","Status",92)

   2: if(Link_XBMC_to_devices=="0")then return false end

   3: are_curtains_open = luup.variable_get("urn:upnp-org:serviceId:Dimming1","LoadLevelStatus",107)

   4: if(are_curtains_open=="100")then

   5:      luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1","RunScene",{SceneNum="138"},0)

   6: end
These are the three regular scenes in Vera, that the Kodi automation scenes run when all the conditions are met. And these scenes ID numbers are the ones referenced in the various LUUP code above etc.

image

Summary

Well I hope this all makes sense as its quite hard to explain. But with the KodiRemote add-ons for Kodi Media Center and Vera, you can integrate the two together and have Vera perform actions based on Kodi’s current media playback status. I am sure there are various ways of setting up your scenes in Vera, I’m for example not using PLEG and tend to just add the LUUP code myself. But as long as you know how to create the triggers with the KodiRemote devices, then you can go about creating the actions for your scenes as you normally would.

Here is a short video clip showing "Video Starting" playback in Kodi. I then pause and resume the video a few times. The video quality isn't great, but you get the idea if you watch it.