# \[BETA\] Device timer

**URL:** <https://community.homey.app/t/beta-device-timer/3347>\
**Category:** Apps\
**Created:** [October 27, 2018, 9:33pm UTC](https://community.homey.app/t/beta-device-timer/3347 "2018-10-27T21:33:21Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![ketra90](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ketra90/32/9687_2.png) [@ketra90](https://community.homey.app/u/ketra90)\
**Post date:** [October 27, 2018, 9:33pm UTC](https://community.homey.app/t/beta-device-timer/3347/1 "2018-10-27T21:33:21Z")

</div>

# Device timer
An app for Switching lights based on the name of a motion sensor.
## description
This app makes it possible to switch lights based on the name of a motion sensor.

_example_  
` PIRDN5Bathroom `  
switches a light named Bathroom for 5 minutes to 75 or 35 percent (depending on the light level and time of day)

## Working
The Following things will allow the app to identify motion sensor settings:
- prefix (default PIR but changeble in settings) wil tell the app what motion sensors to monitor.
- Dimmer identifier (if enabled and set) will allow the light to be switched to 75 or 35 % based on time of day
- Night identifier will tell the lamp to only switch the lamp during sundown and dark\*
- number will tell the lamp how many minutes the light must stay on after motion is no longer detected.
- switchname will tell the app what light to switch (at the moment only 1 switch is possible)

\*if the motion sensor has lumninance

## TODO

1. Allow the setting of wildcard to switch multiple lights.
2. Changing of Night and dimmer identifiers.

### links:
[Github](https://github.com/ketra/nl.ketra.devicetimer)

[Homey Appstore](https://apps.athom.com/app/nl.ketra.devicetimer)

---

<div class="post-metadata">

**Author:** ![Adrian\_Rockall](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/adrian_rockall/32/13209_2.png) [@Adrian\_Rockall](https://community.homey.app/u/Adrian_Rockall)\
**Post date:** [October 28, 2018, 7:51am UTC](https://community.homey.app/t/beta-device-timer/3347/2 "2018-10-28T07:51:48Z")

</div>

It sounds interesting. I installed it but I don’t understand how to configure it.  
I presume it currently only supports one sensor and one light for the whole house?  
What do the ID numbers that can be entered refer to?  
Currently I have a sensor in the hall for the hall light, a sensor in the cloakroom for the cloakroom light and a sensor in the bathroom for the bathroom light. Is it possible to configure all these?

---

<div class="post-metadata">

**Author:** ![ketra90](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ketra90/32/9687_2.png) [@ketra90](https://community.homey.app/u/ketra90)\
**Post date:** [October 28, 2018, 8:15am UTC](https://community.homey.app/t/beta-device-timer/3347/3 "2018-10-28T08:15:56Z")

</div>

Yes it is possible to configure all of these,

So example for the hall light,  
lightname: Hallway  
motionsensor name should be something like :  
PIRDN5Hallway

PIR = Prefix  
D = dimmer identifier  
N = night identifier  
5 = time  
Hallway = lampname

The settings allows to change the location of certain identifiers and or disable them

There is a fix waiting for approval in the store to fix the location of the identifier, with version 0.0.1 the number must be 1 lower than the actual location

So in the above example for version 0.0.1 the settings are  
Night = Enabled  
Dimmer = Enabled  
Night location = 4  
Dimmer location = 3  
Time location = 5  
Devicename location = 6

With version 0.0.4 this should be changed to  
Night location = 5  
Dimmer location = 4  
Time location = 6  
Devicename location 7

Makes sense?

Summary the name of the motion sensor will set how to switch a light.

PIRDN5CloakRoom switches CloakRoom  
PIRDN5Bathroom switches Bathroom  
PIRDN5Hallway switches Hallway

---

<div class="post-metadata">

**Author:** ![Adrian\_Rockall](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/adrian_rockall/32/13209_2.png) [@Adrian\_Rockall](https://community.homey.app/u/Adrian_Rockall)\
**Post date:** [October 28, 2018, 10:05am UTC](https://community.homey.app/t/beta-device-timer/3347/4 "2018-10-28T10:05:03Z")

</div>

OK, making more sense now. I was thinking location as in the house lol. Now I see it is the index in the name string of the character.  
So, one of my lights is just On/Off so what would I put in the sensor name instead of ‘D’?  
I can’t get the light to come on. I have covered the light sensor so it is reporting 7 lux and I have set the start day to be 10:00:00 (currently 9:50). I waited until the senor motion alarm was off and then moved so it triggered but the light does not come on.  
My light is a virtual switch as it’s controlled by a gen 2 LightWave dimmer which is not supported by Homey. So the virtual switch triggers automations in Apple Homekit. It was working via the State Control app so I know the switch woks via flows.  
Initially my switch was called “Hall Light” so I tried taking the space out and changing the motion sensor name to match but the made no difference.

---

<div class="post-metadata">

**Author:** ![ketra90](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ketra90/32/9687_2.png) [@ketra90](https://community.homey.app/u/ketra90)\
**Post date:** [October 28, 2018, 10:17am UTC](https://community.homey.app/t/beta-device-timer/3347/5 "2018-10-28T10:17:52Z")

</div>

you can try debugging with the homey logger app.

i will further look at it when i get home  
and instead of the D just any other character will do

---

<div class="post-metadata">

**Author:** ![Adrian\_Rockall](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/adrian_rockall/32/13209_2.png) [@Adrian\_Rockall](https://community.homey.app/u/Adrian_Rockall)\
**Post date:** [October 28, 2018, 1:05pm UTC](https://community.homey.app/t/beta-device-timer/3347/6 "2018-10-28T13:05:13Z")

</div>

The debug log looks like:

- [Realtime logging](javascript:showPanel(1))

- [Configuration](javascript:showPanel(2))

- [Performance](javascript:showPanel(3))

| Date and time | Component | Event | Details |
| --- | --- | --- | --- |
| 2018-10-28 12:50:29.108 | Device Timer | Nl.ketra.devicetimer | Checking for devices to turn off |
| 2018-10-28 12:49:59.106 | Device Timer | Nl.ketra.devicetimer | Checking for devices to turn off |
| 2018-10-28 12:49:53.034 | PIR0N1Hall Light | Alarm\_motion | |
| 2018-10-28 12:49:50.526 | PIR0N1Hall Light | Measure\_luminance | 1 |
| 2018-10-28 12:49:40.629 | PIR0N1Hall Light | Measure\_luminance | 2 |
| 2018-10-28 12:49:39.714 | PIR0N1Hall Light | Measure\_humidity | 37 |
| 2018-10-28 12:49:29.103 | Device Timer | Nl.ketra.devicetimer | Checking for devices to turn off |
| 2018-10-28 12:49:11.913 | PIR0N1Hall Light | Alarm\_motion | true |
| 2018-10-28 12:49:00.445 | PIR0N1Hall Light | Measure\_luminance | 3 |
| 2018-10-28 12:48:59.107 | Device Timer | Nl.ketra.devicetimer | Checking for devices to turn off |
| 2018-10-28 12:48:50.409 | PIR0N1Hall Light | Measure\_luminance | 5 |

I have set the Start time to 15:00 and the current time is 12:53.  
The logger is set to monitor the switch as well but it doesn’t appear to be set.

Just to show that I thought I would log manually switching the light on and discovered that Device Timer will switch the light off (2018-10-28 12:57:29.176):

- [Realtime logging](javascript:showPanel(1))

- [Configuration](javascript:showPanel(2))

- [Performance](javascript:showPanel(3))

| Date and time | Component | Event | Details |
| --- | --- | --- | --- |
| 2018-10-28 12:59:59.192 | Device Timer | Nl.ketra.devicetimer | Checking for devices to turn off |
| 2018-10-28 12:59:29.111 | Device Timer | Nl.ketra.devicetimer | Checking for devices to turn off |
| 2018-10-28 12:59:12.929 | PIR0N1Hall Light | Alarm\_motion | |
| 2018-10-28 12:58:59.127 | Device Timer | Nl.ketra.devicetimer | Checking for devices to turn off |
| 2018-10-28 12:58:41.737 | PIR0N1Hall Light | Measure\_luminance | |
| 2018-10-28 12:58:40.793 | PIR0N1Hall Light | Measure\_humidity | 38 |
| 2018-10-28 12:58:32.903 | PIR0N1Hall Light | Alarm\_motion | true |
| 2018-10-28 12:58:29.107 | Device Timer | Nl.ketra.devicetimer | Checking for devices to turn off |
| 2018-10-28 12:57:59.121 | Device Timer | Nl.ketra.devicetimer | Checking for devices to turn off |
| 2018-10-28 12:57:29.723 | Hall Light | Onoff | |
| 2018-10-28 12:57:29.176 | Device Timer | Nl.ketra.devicetimer | Hall Light is on. switching off |
| 2018-10-28 12:57:29.172 | Device Timer | Nl.ketra.devicetimer | Checking for devices to turn off |
| 2018-10-28 12:57:03.142 | Hall Light | Onoff | true |
| 2018-10-28 12:56:59.178 | Device Timer | Nl.ketra.devicetimer | Checking for devices to turn off |
| 2018-10-28 12:56:57.254 | Hall Light | Onoff | |
| 2018-10-28 12:56:47.815 | Hall Light | Onoff | true |
| 2018-10-28 12:56:15.575 | PIR0N1Hall Light | Alarm\_motion | |

But as you can see it is not switched back on when the sensor triggers.

---

<div class="post-metadata">

**Author:** ![ketra90](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ketra90/32/9687_2.png) [@ketra90](https://community.homey.app/u/ketra90)\
**Post date:** [October 28, 2018, 1:18pm UTC](https://community.homey.app/t/beta-device-timer/3347/7 "2018-10-28T13:18:25Z")

</div>

It looks like the app does not listen to the motionsensor. Try setting the prefix in the settings page to PIR and restart the app after doing so

---

<div class="post-metadata">

**Author:** ![Adrian\_Rockall](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/adrian_rockall/32/13209_2.png) [@Adrian\_Rockall](https://community.homey.app/u/Adrian_Rockall)\
**Post date:** [October 28, 2018, 1:39pm UTC](https://community.homey.app/t/beta-device-timer/3347/8 "2018-10-28T13:39:09Z")

</div>

I already had Prefix set to PIR so I just restarted the app. Now the light stays on 🙂  
The log is:

- [Realtime logging](javascript:showPanel(1))

- [Configuration](javascript:showPanel(2))

- [Performance](javascript:showPanel(3))

| Date and time | Component | Event | Details |
| --- | --- | --- | --- |
| 2018-10-28 13:28:45.832 | Device Timer | Settings.set | PIR0N1Hall Light |
| 2018-10-28 13:28:45.619 | Device Timer | Nl.ketra.devicetimer | Device Changed state TriggerMotion |
| 2018-10-28 13:28:45.617 | Device Timer | Nl.ketra.devicetimer | stateChange: PIR0N1Hall Light |
| 2018-10-28 13:28:45.573 | PIR0N1Hall Light | Measure\_luminance | 125 |
| 2018-10-28 13:28:44.830 | Device Timer | Settings.set | PIR0N1Hall Light |
| 2018-10-28 13:28:44.656 | Device Timer | Nl.ketra.devicetimer | Device Changed state TriggerMotion |
| 2018-10-28 13:28:44.655 | Device Timer | Nl.ketra.devicetimer | stateChange: PIR0N1Hall Light |
| 2018-10-28 13:28:44.622 | PIR0N1Hall Light | Measure\_humidity | 37 |
| 2018-10-28 13:28:35.375 | Device Timer | Settings.set | PIR0N1Hall Light |
| 2018-10-28 13:28:35.169 | Device Timer | Nl.ketra.devicetimer | Device Changed state TriggerMotion |
| 2018-10-28 13:28:35.168 | Device Timer | Nl.ketra.devicetimer | stateChange: PIR0N1Hall Light |
| 2018-10-28 13:28:35.145 | PIR0N1Hall Light | Measure\_luminance | 124 |
| 2018-10-28 13:28:29.222 | Device Timer | Nl.ketra.devicetimer | Checking for devices to turn off |
| 2018-10-28 13:28:25.363 | Device Timer | Settings.set | PIR0N1Hall Light |
| 2018-10-28 13:28:25.148 | Device Timer | Nl.ketra.devicetimer | Device Changed state TriggerMotion |
| 2018-10-28 13:28:25.147 | Device Timer | Nl.ketra.devicetimer | stateChange: PIR0N1Hall Light |
| 2018-10-28 13:28:25.126 | PIR0N1Hall Light | Measure\_luminance | 127 |
| 2018-10-28 13:28:15.355 | Device Timer | Settings.set | PIR0N1Hall Light |
| 2018-10-28 13:28:15.129 | Device Timer | Nl.ketra.devicetimer | Device Changed state TriggerMotion |
| 2018-10-28 13:28:15.128 | Device Timer | Nl.ketra.devicetimer | stateChange: PIR0N1Hall Light |
| 2018-10-28 13:28:15.099 | PIR0N1Hall Light | Measure\_luminance | 119 |
| 2018-10-28 13:28:05.388 | Device Timer | Settings.set | PIR0N1Hall Light |
| 2018-10-28 13:28:05.181 | Device Timer | Nl.ketra.devicetimer | Device Changed state TriggerMotion |
| 2018-10-28 13:28:05.177 | Device Timer | Nl.ketra.devicetimer | stateChange: PIR0N1Hall Light |
| 2018-10-28 13:28:05.082 | PIR0N1Hall Light | Measure\_luminance | 116 |
| 2018-10-28 13:27:59.188 | Device Timer | Nl.ketra.devicetimer | Checking for devices to turn off |
| 2018-10-28 13:27:45.278 | Device Timer | Settings.set | PIR0N1Hall Light |

So it now seems to treat the luminance change as motion.  
On previous changes to the settings I had just hit Save and had not restarted the app.  
Just from interest, what is the luminance level that determines night time?

I have also tried to switch of the N field but that has made no difference.

---

<div class="post-metadata">

**Author:** ![ketra90](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ketra90/32/9687_2.png) [@ketra90](https://community.homey.app/u/ketra90)\
**Post date:** [October 28, 2018, 1:41pm UTC](https://community.homey.app/t/beta-device-timer/3347/9 "2018-10-28T13:41:36Z")

</div>

Just out of interest what kind of motionsensor is it?

Night time is considered at 50 lux or lower

I will look in code why the state change is treated as motion

---

<div class="post-metadata">

**Author:** ![Adrian\_Rockall](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/adrian_rockall/32/13209_2.png) [@Adrian\_Rockall](https://community.homey.app/u/Adrian_Rockall)\
**Post date:** [October 28, 2018, 1:48pm UTC](https://community.homey.app/t/beta-device-timer/3347/10 "2018-10-28T13:48:06Z")

</div>

It is an Aeotec MultiSensor 6.  
Thanks.

---

<div class="post-metadata">

**Author:** ![ketra90](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ketra90/32/9687_2.png) [@ketra90](https://community.homey.app/u/ketra90)\
**Post date:** [October 28, 2018, 1:57pm UTC](https://community.homey.app/t/beta-device-timer/3347/11 "2018-10-28T13:57:35Z")

</div>

> [@Adrian\_Rockall](#):
>
> It is an Aeotec MultiSensor 6.  
> Thanks.

I checked the code, as long as the motion sensor has Alarm\_Motion = YEs every update to the sensor will make it seem like it will trigger motion, as soon as its False it will no longer trigger and should be fine.

so kinda working as intended.

---

<div class="post-metadata">

**Author:** ![Adrian\_Rockall](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/adrian_rockall/32/13209_2.png) [@Adrian\_Rockall](https://community.homey.app/u/Adrian_Rockall)\
**Post date:** [October 28, 2018, 2:31pm UTC](https://community.homey.app/t/beta-device-timer/3347/12 "2018-10-28T14:31:52Z")

</div>

All seems OK now.  
I reset all the settings now I understand what they should be, waited for the motion to turn off, switched the light off and then restarted the app.  
Maybe the only issue was not realising the app needs to be restarted after saving the settings so once I had started it with the wrong settings my changes were having no affect.

---

<div class="post-metadata">

**Author:** ![ketra90](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ketra90/32/9687_2.png) [@ketra90](https://community.homey.app/u/ketra90)\
**Post date:** [October 28, 2018, 2:33pm UTC](https://community.homey.app/t/beta-device-timer/3347/13 "2018-10-28T14:33:16Z")

</div>

Aah ok thanks for that feedback i will look into resetting the listeners when settings are saved

---

<div class="post-metadata">

**Author:** ![ketra90](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ketra90/32/9687_2.png) [@ketra90](https://community.homey.app/u/ketra90)\
**Post date:** [December 18, 2018, 1:32pm UTC](https://community.homey.app/t/beta-device-timer/3347/14 "2018-12-18T13:32:44Z")

</div>

Alpha-V2 is in alpha channel If ppl want to test please PM me your email address you use for the homey.
