Restriction restricts a device from changing states when restriction is triggered. Restriction can be a bit difficult to use because sources and targets must be defined before the device with the restriction attribute.
Syntax:
restriction={
Attribute.STATE: State.<State>,
Attribute.SOURCE: <source device>
Attribute.TARGET: <target device>, <-- Optional
Attribute.START: <time> <-- "
Attribute.END:
<time> <-- "
},
<time> can be:'HH:MM' 'HH:MM:SS' 'HH:MMam|pm' HH:MM:SSam|pm or
(seconds, minutes, hours, day-of-month, month, day-of-week)
Examples:
'16:30' - 24 hour clock
'16:30:25'
'4:30pm' - 12 hour clock
'4:30:25pm'
'4:30am'
('*',30,16,'*','*','*') <- 4:30pm in cron format
('*',0,9,'*','*',5) <- 9:00am on Saturdays only
Example:
In this example, when the device "away" changes to the ON state, the "test" light will be restricted from changing states.
test = Light(address='L3', devices=(hue, away),
restriction={
Attribute.STATE: State.ON,
Attribute.SOURCE: away,
},
name="test light"
)
Here is the same command as above but it only is effective between 10:10pm and 7:00am
test = Light(address='L3', devices=(hue, away),
restriction={
Attribute.STATE: State.ON,
Attribute.SOURCE: away,
Attribute.START: '10:10pm'
Attribute.END: '7:00am'
},
name="test light"
)