[BETA] Device timer

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

Homey Appstore

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?

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

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.

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

The debug log looks like:

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

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

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

       Keep this page open. Realtime logging will stop when you leave this page.
    
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))

       Keep this page open. Realtime logging will stop when you leave this page.
    
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.

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

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

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

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

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

       Keep this page open. Realtime logging will stop when you leave this page.
    
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.

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

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.

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.

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

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