Hello everyone,
I’m working on optimizing my house shutdown automation and need some advice on implementing a more granular room-based control system, especially with multiple family members.
Current Setup:
- 4 family members (2 adults, 2 children)
- Each person has three states: “absent”, “sleeping”, or “awake”
- I have created computed items that combine these states for different zones and floors (e.g., “sleeping_or_absent”, “awake_or_absent”) to manage intermediate states for each area of the house
What I’m trying to achieve:
-
Different shutdown scenarios based on who is sleeping/absent:
- When my wife goes to bed: shutdown bedroom and her office (turn off lights, shutdown PC, etc.)
- When I go to bed after her: no need to shutdown bedroom again, but shutdown additional areas (e.g., living room media box)
- The same applies in reverse: if I go to bed first, my rooms are shut down, and when my wife follows, her additional rooms are shut down
- When Child1 goes to bed: shutdown their bedroom
- When Child2 goes to bed: shutdown their bedroom and complete shutdown of remaining upstairs areas
- Again the same applies in reverse
-
Morning scenarios:
- On weekends, when one child wakes up (deactivates sleep item): activate their room, kitchen, and living room (lights, devices, etc.)
- When both children are awake: activate all devices and systems in the entire upstairs area
-
Future expansion:
- This is just the beginning - I plan to add many more rules for different scenarios and combinations of presence/absence/sleeping states
- Need a solution that scales well with additional rules
Current Challenges:
- Rule conflicts: For example, when I’m the last person going to bed, my “sleeping” state triggers multiple rules simultaneously:
- A rule for bedroom and ground floor
- Another rule for the rest of the house (which includes the ground floor)
This leads to error messages about rules not being able to execute because they’re already running, as they’re trying to control the same devices at the same time.
- Avoiding duplicate commands: Need to prevent sending redundant ON/OFF commands to devices that are already in the desired state
- Managing the complexity of 81 possible states (3 states × 4 people)
Current Implementation Attempt:
I initially tried using helper items for each room to prevent multiple activations, but this seems to make things more complicated. I understand I should check item states before sending commands to avoid unnecessary switching, but I’m struggling with how to implement this complex state management efficiently. I’ve read about using state machines, but I’m not sure how to adapt this to my use case.
Through a thread about reusable code, I’ve found a potential solution for this, but I don’t want to mention it here to avoid influencing your suggestions.
Has anyone implemented something similar? What would be the most efficient way to manage these multiple states and conditions?
Thank you for any guidance!