Hi,
I wanted to create a virtual device "Occupancy" that displays the names of who is at home.
The same virtual device will also be very useful to ensure that heating goes off if no one is at home and also to sound alarm sirens if motion is detected internally when no one is at home.
Basically I treat a counter "OccupancyIndex" like a set of Binary switches with 0 = home and 1= away. One switch for each user. The resulting number in decimal determines who is at home and who is away so I can display a label appropriately.
Below I describe how I did it but my question is:
Is there a better way to do this WITHOUT scripting?
Virtual devices created
Occupancy: status values will be
1. "All away"
2. "John"
3. "Jane"
4. "John and Jane"
5. "Mark"
6. "Mark and John"
7. "Mark and Jane"
8. "Mark, John and Jane"
John home (three status values "Home" "Away" "Holiday"). I can manually set them on Holiday if needed
Jane home (three status values "Home" "Away" "Holiday"). I can manually set them on Holiday
Mark home (three status values "Home" "Away" "Holiday"). I can manually set them on Holiday
The next three virtual devices are created by PHLocation2 used alongside GeoFency in iPhones
John geofence
Jane geofence
Mark geofence
Lastly I needed a Counter:
OccupancyIndex
Next I created a series of events to tie it all together. I created the following 14 events
Events created
Event 1
If "John goefence" = entering home then
Virtual device "John home" to On
AND
Increment OccupancyIndex counter by 1
Event 2
If "John geofence" = leaving home then
Virutal device "John home" to Off
AND
Decrement OccupancyIndex counter by 1
Event 3
If "Jane goefence" = entering home then
Virtual device "Jane home" to On
AND
Increment OccupancyIndex counter by 2
Event 4
If "Jane geofence" = leaving home then
Virutal device "Jane home" to Off
AND
Decrement OccupancyIndex counter by 2
Event 5
If "Mark goefence" = entering home then
Virtual device "Mark home" to On
AND
Increment OccupancyIndex counter by 4
Event 6
If "Mark geofence" = leaving home then
Virutal device "Mark home" to Off
AND
Decrement Occupancy counter by 4
Event 7
If OccupancyIndex = 0
Then set Virtual Device Occupancy "All away"
Event 8
If OccupancyIndex = 1
Then set Virtual Device Occupancy "John"
Event 9
If OccupancyIndex = 2
Then set Virtual Device Occupancy "Jane"
Event 10
If OccupancyIndex = 3
Then set Virtual Device Occupancy "John and Jane"
Event 11
If OccupancyIndex = 4
Then set Virtual Device Occupancy "Mark"
Event 12
If OccupancyIndex = 5
Then set Virtual Device Occupancy "Mark and John"
Event 13
If OccupancyIndex = 6
Then set Virtual Device Occupancy "Mark and Jane"
Event 14
If OccupancyIndex = 7
Then set Virtual Device Occupancy "Mark John and Jane"
So, is there a better way to do this WITHOUT scripting?
Thanks for your considerations.
/Marcus
I wanted to create a virtual device "Occupancy" that displays the names of who is at home.
The same virtual device will also be very useful to ensure that heating goes off if no one is at home and also to sound alarm sirens if motion is detected internally when no one is at home.
Basically I treat a counter "OccupancyIndex" like a set of Binary switches with 0 = home and 1= away. One switch for each user. The resulting number in decimal determines who is at home and who is away so I can display a label appropriately.
Below I describe how I did it but my question is:
Is there a better way to do this WITHOUT scripting?
Virtual devices created
Occupancy: status values will be
1. "All away"
2. "John"
3. "Jane"
4. "John and Jane"
5. "Mark"
6. "Mark and John"
7. "Mark and Jane"
8. "Mark, John and Jane"
John home (three status values "Home" "Away" "Holiday"). I can manually set them on Holiday if needed
Jane home (three status values "Home" "Away" "Holiday"). I can manually set them on Holiday
Mark home (three status values "Home" "Away" "Holiday"). I can manually set them on Holiday
The next three virtual devices are created by PHLocation2 used alongside GeoFency in iPhones
John geofence
Jane geofence
Mark geofence
Lastly I needed a Counter:
OccupancyIndex
Next I created a series of events to tie it all together. I created the following 14 events
Events created
Event 1
If "John goefence" = entering home then
Virtual device "John home" to On
AND
Increment OccupancyIndex counter by 1
Event 2
If "John geofence" = leaving home then
Virutal device "John home" to Off
AND
Decrement OccupancyIndex counter by 1
Event 3
If "Jane goefence" = entering home then
Virtual device "Jane home" to On
AND
Increment OccupancyIndex counter by 2
Event 4
If "Jane geofence" = leaving home then
Virutal device "Jane home" to Off
AND
Decrement OccupancyIndex counter by 2
Event 5
If "Mark goefence" = entering home then
Virtual device "Mark home" to On
AND
Increment OccupancyIndex counter by 4
Event 6
If "Mark geofence" = leaving home then
Virutal device "Mark home" to Off
AND
Decrement Occupancy counter by 4
Event 7
If OccupancyIndex = 0
Then set Virtual Device Occupancy "All away"
Event 8
If OccupancyIndex = 1
Then set Virtual Device Occupancy "John"
Event 9
If OccupancyIndex = 2
Then set Virtual Device Occupancy "Jane"
Event 10
If OccupancyIndex = 3
Then set Virtual Device Occupancy "John and Jane"
Event 11
If OccupancyIndex = 4
Then set Virtual Device Occupancy "Mark"
Event 12
If OccupancyIndex = 5
Then set Virtual Device Occupancy "Mark and John"
Event 13
If OccupancyIndex = 6
Then set Virtual Device Occupancy "Mark and Jane"
Event 14
If OccupancyIndex = 7
Then set Virtual Device Occupancy "Mark John and Jane"
So, is there a better way to do this WITHOUT scripting?
Thanks for your considerations.
/Marcus
Comment