blueprint: name: Room Occupancy description: "## Room Occupancy\n\nThis blueprint will turn on and off the\ \ input_boolean associated with the occupancy of a room. The room will need an input_boolean\ \ to use for determining if it is occupied. It will also need an input_select to determine\ \ whether the room is in Auto mode, Manual mode, or forcefully off.\n\nIf specified\ \ a switch will also be turned off when the room is in Guest mode" domain: automation input: room_occupied: name: Room Occupied description: The Input_Boolean that should be turned off selector: entity: domain: input_boolean home_occupied: name: Home Occupied description: The Input_Boolean that describes whether the home is occupied default: input_boolean.home_occupied selector: entity: domain: input_boolean binary_sensor: name: Binary Sensor description: The Binary_Sensor that describes whether the room is occupied selector: entity: domain: binary_sensor delay_seconds: name: Delay Seconds description: The number of seconds to wait after the binary sensor turns off default: 300 selector: number: min: 0 max: 3600 unit_of_measurement: seconds house_mode: name: House Mode (Optional) description: The Input_Select that describes what mode the house is in. default: input_select.house selector: entity: domain: input_select manual_option: name: Manual Option (optional) description: The Input_Select option that implies the House is in Manual mode. default: Manual selector: text: mode: restart trigger: - platform: state entity_id: !input home_occupied from: 'on' to: 'off' - platform: state id: room_occupied entity_id: !input binary_sensor from: 'off' to: 'on' - platform: state id: 'not_occupied' entity_id: - !input home_occupied - !input binary_sensor to: 'off' for: seconds: !input delay_seconds - platform: time_pattern id: 'time_pattern' minutes: "/5" condition: - condition: or conditions: - alias: "Home not occupied" condition: state entity_id: !input home_occupied state: 'off' - alias: "Room just occupied" condition: trigger id: room_occupied - alias: "Room not occupied" condition: and conditions: - condition: state entity_id: !input room_occupied state: 'on' - condition: state entity_id: !input binary_sensor state: 'off' action: - choose: - alias: "Home not occupied" conditions: - condition: state entity_id: !input home_occupied state: 'off' sequence: - service: homeassistant.turn_off entity_id: !input room_occupied - alias: "Room not occupied" conditions: - condition: trigger id: not_occupied - condition: not conditions: - condition: state entity_id: !input house_mode state: !input manual_option sequence: - service: homeassistant.turn_off entity_id: !input room_occupied - alias: "Room occupied" conditions: - condition: trigger id: room_occupied sequence: - service: homeassistant.turn_on entity_id: !input room_occupied - alias: "Time pattern" conditions: - condition: trigger id: time_pattern - condition: state entity_id: !input room_occupied state: 'on' - condition: state entity_id: !input binary_sensor state: 'off' for: seconds: !input delay_seconds sequence: - service: homeassistant.turn_off entity_id: !input room_occupied