The last day of March was supposed to be the first day of income tax preparation. Procrastinating proved more appealing and the best strategy was to do a test installation of a new IKEA zigbee VALLHORN motion sensor type E2134 picked up about a month ago. There's a very high likelihood that the sensor will be moved. When that time comes, I will have forgotten everything; hence this post to document how it was done. So this is by no means an in-depth review of the sensor.
The recently introduced VALLHORN motion sensor is probably meant to replace the older TRÅDFRI models: type E1745 and type E1525. These older models were not in the Halifax (Canada) IKEA store when I purchased the VALLHORN and can't be found in the online catalogue in Canada. The image to the left shows that the E1745 is currently (April 2, 2024) available in the USA, but presumably only until the stock is exhausted.
The new VALLHORN is big, relatively speaking. Its face is a rounded 71 x 71 mm square and it is 34.5 mm deep, 38.4 mm if the sensor is inserted into its mounting bracket. Because of the bigger size the sensor is powered by two AAA batteries instead of coin cells. It could result in longer periods between battery replacements although I will not be able to verify that because I do not have any of the older IKEA motion sensors.
The Blakadder description of the older sensors reveals that the new sensor adds illuminance level to the occupancy and battery percentage measurements. This is useful because the test installation consists of using the VALLHORN to turn on lights in a stairway as someone approaches if the light level is below a set threshold. The two three-way switches that turn the lights on or off from either stair landings are connected to a Shelly 1 with Tasmota firmware. When the light is turned on, a timer is set and after five minutes it automatically turns off the light. This is enabled in Domoticz, our home automation server. Thus, all the heavy lifting is done by the existing home automation system, the VALLHORN will just trigger existing routines. Of course, the sensor must be paired with the Zigbee coordinator of the home automation system which in our case is a Sonoff ZbBridge with ZigbeeToTasmota
.
While the IKEA recommended Zigbee hub was not needed in this configuration, full functionality of the sensor may not be exploited. Presumably, one could set the threshold level for the 0x0006 On/Off cluster messages it sends to a paired light, the hub, or some other zigbee device or devices. The test installation will ignore such messages and our home automation system will use only three messages from the sensor once it is paired with the system's zigbee coordinator.
Zigbee attribute | Type | ZigbeeToTasmota message |
---|---|---|
Illuminance | non negative integer | {"ZbReceived":{"0xB8BC":{"Device":"0xB8BC","Illuminance":20969,"Endpoint":3,"LinkQuality":55}}} |
Occupancy | 0 or 1 | {"ZbReceived":{"0xB8BC":{"Device":"0xB8BC","Occupancy":1,"Endpoint":2,"LinkQuality":13}}} |
BatteryPercentage | 0...100 | {"ZbReceived":{"0xB8BC":{"Device":"0xB8BC","BatteryVoltage":2.7,"BatteryPercentage":90,"Endpoint":1,"LinkQuality":52}}} |
The ZigbeeToTasmota
messages shown above are actually the translation of the sensor Zigbee Messages done by the Tasmota software. These are visible in the Tasmota console of the ZbBridge.
Since the illuminance is only reported when it changes, values sent by the sensor must be stored by Domoticz. A user-defined variable seemed like the best way of doing this. The following screen capture shows how to get to the User variables
settings page in the Domoticz web interface.
Adding a variable is done by specifying its name, type and intial value.
Then it is necessary to click on the stair_illuminance
was assigned the idx value 4.
I suppose one could add a (hidden) virtual light switch in Domoticz to take activate the stair lights, but there is already a virtual switch running the aforementioned Shelly 1. Instead another user variable, named stair_occupancy
or whatever one prefers, was created. It was assigned idx 5.
The next step is to add Tasmota rules in the Zigbee coordinator. In my case, I appended three rules to Rule3
.
As can be seen these rules define MQTT messages published in response to the Zigbee message from the sensor. The MQTT messages all have the domoticz/in
topic to which Domoticz is automatically subscribed by default if the MQTT Client Gateway is installed in the system's Hardware
. This is a choice on my part, and HTTP requests sent directly to Domoticz could be used instead.
The third rule is to update a virtual percentage sensor added in Domoticz to display the battery level and to send out a notification if the level drops below say 60%. Its idx is 225.
The last part of the puzzle is a rather simple dzVents Lua script that will be triggered by any change in the stair_occupancy
user variable.
I think the logic here is pretty clear. The execute
function will be executed (of course!) whenever the value of variable 5 changes. If that value is greater than one, that means that the detector sensed motion as someone is approached the stairs. In that case the stair light is switched on as long as the illuminance is below the 4000 threshold.
Notes or random information and ideas.
- An important reference: ZigBee Cluster Library Specification. Not the latest version, but probably quite adequate for most sensors on the market at this point. Abbreviated [ZCL] below.
- The "0x0006 On/Off cluster messages" sent by the VALLHORN look like this
{"Device":"0xB8BC","0006!42":"0158020000","Power":1,"PowerOnlyWhenOn":1,"PowerOnTime":60,"PowerOffWait":0,"Endpoint":1,"LinkQuality":65}
Here,0x0006!42
is a "On with timed off" message. See [ZCL] pg 3-54. - An argument could have been made to use a Lux virtual sensor rather than a user variable to store the illuminance reported by the sensor. Unlike a user variable, a Domoticz sensor has data logging capabilities, which would make it easier to determine the appropriate threshold below which the stair light should be turned on. I compromised and did both, setting up the user variable as described above and a temporary Lux sensor. Then I modified the
dzVents
script.--[[ Turn "stair_light" on when "stair_occupancy" > 1 and stair_illuminance < 4000 stair_light: switch idx 138, stair_occupancy: user-variable idx 5, stair_illumnance: user-variable idx 4, stair_lux: lux sensor idx 226. ]] return { on = { variables = { 4, 5 } }, execute = function(dz, variable) if variable.id == 4 then dz.devices(226).updateLux(variable.value) else if ( (variable.value > 0) and (dz.variables(4).value < 4000) ) then dz.devices(138).switchOn() end end end }After some tests, it will be easier to fine-tune the threshold value.
The above is the graphic log for the luminescence measurement in the early afternoon of a cloudy day.
- According to [ZCL] 4.2 Illuminance Measurement, the measured light level should be a 16-bit integer between 0 and 65355 (0xFFFF). If zero then the light level was too low to measure and if equal to 0xFFFF then the measurement was invalid. For values in between, the illuminance, measured in lux is calculated from the measured value (mv) as follows:
lux = 1O^(0.0001*mv)-1
or at least I think that's what it says on pg 4-5 [ZCL]. It does not really matter, only an appropriate threshold value is needed no matter its measurement units. The 4000 magic value used in the two scripts was almost picked out of mid-air, but it works as a first approximation and will be refined later. - Instructions to pair the VALLHORN.
IKEA instructions: Getting started without DIRIGERA hub
- Make sure the smart product you want to connect is installed and powered on.
- Hold the motion sensor close to the smart product (less than 5 cm away).
- Press and hold the Pairing button for at least 10 seconds. A red LED will steadily shine under the lens of the motion sensor. The smart product will pulse with a white LED once connected
mihailmoise on the Home Assistant community:
In order to add these vallhorn things you need to push the vallhorn device link button 4 times in max 5 sec, as stated by device’s specs to factory reset. They’ll be then found and added to your devices list. Don’t push the link button for “at least 10 seconds” - Ikea advice, I think you have better things to do with your time.