I've installed a couple of occupancy sensors and would like to control lighting with them. To start off I added the SmartRooms Class from the Premise help. I quickly found it had errors in the code that didn't allow it to work. I then tried writing my own code (I have no experience writing code). I managed to setup a OnChangeMotionDetected script that kinda works.
This works as long as it is before midnight. I assume that at midnight sysSunset move to the next day and therefore the check is no longer true, and it falls through the logic check.
I also tried:
This causes a impending overflow error. Again I am assuming this is due to the sysSunset and sysSunrise potentially being different days.
So..............
How do you all have your occupancy sensors setup?
Ultimately I would like to be able to have multiple brightnesses depending on the time of day and the state of my alarm panel. Any examples would be much appreciated.
Kaz
Code:
If Home.House.Second_Floor.Master_Bathroom.Occupancy = True Then
If system.times.sysTime > system.times.sysSunset(system.times.sysDate) Then
Home.House.Second_Floor.Master_Bathroom.RecessedLight.PowerState = True
addTimer 180,"Home.House.Second_Floor.Master_Bathroom.RecessedLight.PowerState = False",1,this.Name
End If
End If
This works as long as it is before midnight. I assume that at midnight sysSunset move to the next day and therefore the check is no longer true, and it falls through the logic check.
I also tried:
Code:
If Home.House.Second_Floor.Master_Bathroom.Occupancy = True Then
If system.times.sysTime > system.times.sysSunset(system.times.sysDate) And _
system.times.sysTime < system.times.sysSunRise(system.times.sysDate)
Home.House.Second_Floor.Master_Bathroom.RecessedLight.PowerState = True
addTimer 180,"Home.House.Second_Floor.Master_Bathroom.RecessedLight.PowerState = False",1,this.Name
End If
End If
This causes a impending overflow error. Again I am assuming this is due to the sysSunset and sysSunrise potentially being different days.
So..............
How do you all have your occupancy sensors setup?
Ultimately I would like to be able to have multiple brightnesses depending on the time of day and the state of my alarm panel. Any examples would be much appreciated.
Kaz