Can someone please help. Trying to learn RM (I'm coming from ST and webCore). I'm trying to make this in RM since I understand that's preferred over WC and can't for the life of me figure out how to start. I'm good at looking at rules and figuring out how folks did them, but can't figure out how to get this started. I also understand I could use Mode Manager, but I tried that too, and it didn't fire off like it should have.
execute
only when
Visitor's switch is off
if
Time is between 5:00:00 AM and 9:00:00 AM
then
ifend if;
if
Any of {Me}'s or {You}'s presence is present
then
withOffice Light Switchdo
Turn off;
end with;
Set location mode to Night;
Set Safety Monitor status to armHome;
else
Set Safety Monitor status to armAway;
Set location mode to Away;
with Office Light Switchdo
Turn on;
end with;
end if;
end if;
if
Time is between 9:00:00 AM and 11:00:00 PM{when true
withSleep Switchdo
Turn off;
end with;
}
then
if
Any of {Me}'s or {You}'s presence is present
then
withOffice Light Switchdo
Turn off;
end with;
Set location mode to Home;
Set Safety Monitor status to armHome;
else
Set Safety Monitor status to armAway;
Set location mode to Away;
withOffice Light Switchdo
Turn on;
end with;
end if;
end if;
if
Time is between 11:00:00 PM and 5:00:00 AM
then
if
Any of {Me}'s or {You}'s presence is present
then
Set location mode to Night;
Set Safety Monitor status to armNight;
else
Set Safety Monitor status to armAway;
Set location mode to Away;
withOffice Light Switchdo
Turn on;
end with;
end if;
end if;
if
All of {Me}'s and {You}'s presence were not present for at least 12 hours{when true
with{lights}do
Set location mode to Extended Away;
Set Safety Monitor status to armAway;
end with;
}
end if;
ifend if;
Set piston state to "{$locationMode " was initiated on " $now}";
This is a pretty hefty rule. I am not sure of exactly when or how you want it to run. I took the assumption it should run when the presence status changes. If you also want it to run time based you can just add in those triggers. I think this would cover your use case.
Trigger:
Me or You any present
Action:
Cancel Delayed Actions
IF Time is 5 AM to 9AM then
Office Light Turn Off
Set Mode Night
Set HSM armHome
Else IF time is 9A to 11P then
Office Light Turn Off
Set Mode Home
Set HSM armHome
Else if 11P to 5A then
Office Light Turn On
Set Mode Night
Set HSM armNight
End If
Wait for Condition Me or You All not present
IF Time is 5 AM to 9AM then
Office Light Turn On
Set Mode Away
Set HSM armAway
Else IF time is 9A to 11P then
Office Light Turn On
Set Mode Away
Set HSM armAway
Else if 11P to 5A then
Office Light Turn On
Set Mode Away
Set HSM armaway
End If
Set mode Extended Away (delay 12 hours) Cancellable
(then just setup a rule that pauses this rule when the visitor switch is on. )
It might be more practical to set your modes based on time(you can use RM to make the rules to do this). Then you can set HSM based on the presence and mode
This piston actually works in conjunction with the piston below - or basically in opposite.
Any of Me or You presence changes to present
then
/* Disable the SHM /
Set Smart Home Monitor status to off;
/ The below IFs determine what mode to set the home /if /
Time is between 5:00:00 AM and 9:00:00 AM /
then
with /#110/Camera Notificationsdo
Set location mode to Home;
Turn off;
end with;
end if;
if
Time is between 9:00:00 AM and 11:00:00 PM
then
with Camera Notificationsdo
Set location mode to Home;
Turn off; /
end with;
with {:9c1a65a6f2657bbe765e29899f032b89:}do
Turn off;
end with;
end if;
if
Time is between 11:00:00 PM and 5:00:00 AM
then
with Camera Notificationsdo
Set location mode to Night;
Turn on;
end with;
with {:9c1a65a6f2657bbe765e29899f032b89:}do
Turn on;
end with;
end if;
if end if;
end if;
/ This block handles when one of us leaves /if /#78 */
Any of Jerry's or Tanya's presence changes to not present /* #79 */
then
/* This block is for when everyone is gone /if /
All of Me and You presence are not present {when true
with Camera Notificationsdo
Turn on;
end with;
with /{:d99384199d064ce9894239f30ae47b1f:}do
Lock;
end with;
when false}
then
/ Turn off all the lights /with{Lights}do
Set Smart Home Monitor status to away;
Turn off;
end with;
/ Below handles the mode for away */if
Time is between 5:00:00 AM and 9:00:00 AM
then
Set location mode to Away;
end if;
if
Time is between 9:00:00 AM and 11:00:00 PM
then
Set location mode to Away;
end if;
if
Time is between 11:00:00 PM and 5:00:00 AM
then
Set location mode to Night;
end if;
end if;
end if;
end execute;
And what if no one actually leaves - we just "stay" at home. I basically want it to change based on time, not on presence. But presence plays into it as well....just not "arrives" or "leaves" but "present" when the time comes.
It might be best to write this as a series of rules.
Trigger: Time 5:00 AM
Action:
If {Me}'s or {You}'s presence any present
Set Mode Night
Do this for each mode and then do this for away
Trigger: {Me}'s or {You}'s presence any leaves
Action:
Wait for condition {Me}'s or {You}'s presence all not present
set mode away
Wait for condition {Me}'s or {You}'s presence any arrive
If time between 5 and 9
set mode home
else if between 9 and 11
Set mode
else if for everything else you need.
Then in HSM you can set the alarm status based on the modes.