Looking to activate my privacy switches on 3/4 cameras when anyone is home between 12 am and 1 pm each day

I am using the Tapo control to expose the privacy switches to HomeKit. I basically want to create an automation that enables:

switch.alternate_living_room_view_privacy
switch.hallway_privacy
switch.living_room_view_privacy

When:

person.derek_graham or person.maria are home but only during 12 am to 1 pm daily.
And if no one is home or it is not during that time period then those switches are turned off. 

How can I create this?

Whilst you could code this into a single automation, and I probably would, I’d suggest keep it nice and simple with two separate automations:

alias: Cameras on
trigger:
  - platform: state
    entity_id:
      - person.derek_graham
      - person.maria
  - platform: time
    at: "12:00:00"
condition:
  - condition: state
    entity_id:
      - person.derek_graham
      - person.maria
    state: 'home'
    match: any
  - condition: time
    after: "11:59:59"
    before: "13:00:00"
action:
  - action: switch.turn_on
    target:
      entity_id:
        - switch.alternate_living_room_view_privacy
          switch.hallway_privacy
          switch.living_room_view_privacy

and

alias: Cameras off
trigger:
  - platform: state
    entity_id:
      - person.derek_graham
      - person.maria
  - platform: time
    at: "13:00:00"
condition:
  - not:
    - condition: state
      entity_id:
        - person.derek_graham
        - person.maria
      state: 'home'
      match: any
  - or:
    - condition: time
      before: "12:00:00"
    - condition: time
      after: "12:59:59"
action:
  - action: switch.turn_off
    target:
      entity_id:
        - switch.alternate_living_room_view_privacy
          switch.hallway_privacy
          switch.living_room_view_privacy

Thanks this works, I had to edit it a little but it is working!

I noticed that my automations aren’t working, any help would helpful

alias: Turn on Privacy Mode
description: Turns on Privacy Mode for interior cameras
trigger:
  - platform: state
    entity_id:
      - person.derek_graham
      - person.maria
    enabled: true
condition:
  - condition: state
    entity_id:
      - person.derek_graham
      - person.maria
    state: home
    match: any
  - condition: time
    after: "11:59:59"
    before: "13:00:00"
action:
  - action: switch.turn_on
    target:
      entity_id:
        - switch.alternate_living_room_view_privacy
        - switch.hallway_privacy
        - switch.living_room_view_privacy
    data: {}

Second one

alias: Turn off Privacy Mode
description: Turns off Privacy Mode on interior cameras
trigger:
  - platform: state
    entity_id:
      - person.derek_graham
      - person.maria
    enabled: false
  - platform: time
    at: "13:00:00"
condition:
  - not:
      - condition: state
        entity_id:
          - person.derek_graham
          - person.maria
        state: home
        match: any
  - or:
      - condition: time
        before: "12:00:00"
      - condition: time
        after: "12:59:59"
action:
  - action: switch.turn_off
    target:
      entity_id:
        - switch.alternate_living_room_view_privacy
        - switch.hallway_privacy
        - switch.living_room_view_privacy
    data: {}

You’ll have to be a bit more specific. What’s not happening? If your person entities are changing state, the automations will be triggering and generating a trace — look at that to see what’s going wrong.

Three dots / Download trace / paste here as code if you need more help.

The “off” automation has the person state trigger disabled, and why did you remove the 12:00 trigger in the “on” automation?

Here is one trace


  "trace": {
    "last_step": "condition/0/conditions/0/entity_id/1",
    "run_id": "626e3372044ce0dff6a304498a04f1dc",
    "state": "stopped",
    "script_execution": "failed_conditions",
    "timestamp": {
      "start": "2024-10-03T03:12:47.440519+00:00",
      "finish": "2024-10-03T03:12:47.440630+00:00"
    },
    "domain": "automation",
    "item_id": "1727879962748",
    "trigger": "state of person.derek_graham",
    "trace": {
      "trigger/0": [
        {
          "path": "trigger/0",
          "timestamp": "2024-10-03T03:12:47.440534+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "automation.cameras_off",
              "state": "on",
              "attributes": {
                "id": "1727879962748",
                "last_triggered": "2024-10-02T15:16:20.240700+00:00",
                "mode": "single",
                "current": 0,
                "friendly_name": "Turn off Privacy Mode"
              },
              "last_changed": "2024-10-02T19:45:08.418331+00:00",
              "last_reported": "2024-10-02T19:45:08.418331+00:00",
              "last_updated": "2024-10-02T19:45:08.418331+00:00",
              "context": {
                "id": "01J97C7KT256G7JK53ESEP02MC",
                "parent_id": null,
                "user_id": null
              }
            },
            "trigger": {
              "id": "0",
              "idx": "0",
              "alias": null,
              "platform": "state",
              "entity_id": "person.derek_graham",
              "from_state": {
                "entity_id": "person.derek_graham",
                "state": "home",
                "attributes": {
                  "editable": true,
                  "id": "derek_graham",
                  "device_trackers": [
                    "device_tracker.dereks_iphone_15_pro",
                    "device_tracker.ipad"
                  ],
                  "latitude": 41.97349586582725,
                  "longitude": -87.65216647147656,
                  "gps_accuracy": 3,
                  "source": "device_tracker.dereks_iphone_15_pro",
                  "user_id": "2581b06774ae4454b92d26ebf0d627cb",
                  "friendly_name": "Derek Graham"
                },
                "last_changed": "2024-10-02T19:45:00.602403+00:00",
                "last_reported": "2024-10-03T03:04:50.211545+00:00",
                "last_updated": "2024-10-03T03:04:50.211545+00:00",
                "context": {
                  "id": "01J985CQ93Q49PGBDW2WZCFWM6",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "to_state": {
                "entity_id": "person.derek_graham",
                "state": "home",
                "attributes": {
                  "editable": true,
                  "id": "derek_graham",
                  "device_trackers": [
                    "device_tracker.dereks_iphone_15_pro",
                    "device_tracker.ipad"
                  ],
                  "latitude": 41.97349586353138,
                  "longitude": -87.65216645574765,
                  "gps_accuracy": 3,
                  "source": "device_tracker.dereks_iphone_15_pro",
                  "user_id": "2581b06774ae4454b92d26ebf0d627cb",
                  "friendly_name": "Derek Graham"
                },
                "last_changed": "2024-10-02T19:45:00.602403+00:00",
                "last_reported": "2024-10-03T03:12:47.439623+00:00",
                "last_updated": "2024-10-03T03:12:47.439623+00:00",
                "context": {
                  "id": "01J985V9AF31R80F2GY1RF9GKA",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "for": null,
              "attribute": null,
              "description": "state of person.derek_graham"
            }
          }
        }
      ],
      "condition/0": [
        {
          "path": "condition/0",
          "timestamp": "2024-10-03T03:12:47.440550+00:00",
          "result": {
            "result": false
          }
        }
      ],
      "condition/0/conditions/0": [
        {
          "path": "condition/0/conditions/0",
          "timestamp": "2024-10-03T03:12:47.440565+00:00",
          "result": {
            "result": true
          }
        }
      ],
      "condition/0/conditions/0/entity_id/0": [
        {
          "path": "condition/0/conditions/0/entity_id/0",
          "timestamp": "2024-10-03T03:12:47.440579+00:00",
          "result": {
            "result": true,
            "state": "home",
            "wanted_state": "home"
          }
        }
      ],
      "condition/0/conditions/0/entity_id/1": [
        {
          "path": "condition/0/conditions/0/entity_id/1",
          "timestamp": "2024-10-03T03:12:47.440602+00:00",
          "result": {
            "result": true,
            "state": "home",
            "wanted_state": "home"
          }
        }
      ]
    },
    "config": {
      "id": "1727879962748",
      "alias": "Turn off Privacy Mode",
      "description": "Turns off Privacy Mode on interior cameras",
      "trigger": [
        {
          "platform": "state",
          "entity_id": [
            "person.derek_graham",
            "person.maria"
          ]
        },
        {
          "platform": "time",
          "at": "13:00:00"
        }
      ],
      "condition": [
        {
          "not": [
            {
              "condition": "state",
              "entity_id": [
                "person.derek_graham",
                "person.maria"
              ],
              "state": "home",
              "match": "any"
            }
          ]
        },
        {
          "or": [
            {
              "condition": "time",
              "before": "12:00:00"
            },
            {
              "condition": "time",
              "after": "12:59:59"
            }
          ]
        }
      ],
      "action": [
        {
          "action": "switch.turn_off",
          "target": {
            "entity_id": [
              "switch.alternate_living_room_view_privacy",
              "switch.hallway_privacy",
              "switch.living_room_view_privacy"
            ]
          },
          "data": {}
        }
      ]
    },
    "blueprint_inputs": null,
    "context": {
      "id": "01J985V9AG5NZMYHXR4VP6BZQC",
      "parent_id": "01J985V9AF31R80F2GY1RF9GKA",
      "user_id": null
    }
  },
  "logbookEntries": []
}

Second one

{
  "trace": {
    "last_step": "condition/1",
    "run_id": "3b6125847ffe4b9d3337080aa2e5e88e",
    "state": "stopped",
    "script_execution": "failed_conditions",
    "timestamp": {
      "start": "2024-10-03T06:38:55.517474+00:00",
      "finish": "2024-10-03T06:38:55.517644+00:00"
    },
    "domain": "automation",
    "item_id": "1727879927210",
    "trigger": "state of person.derek_graham",
    "trace": {
      "trigger/0": [
        {
          "path": "trigger/0",
          "timestamp": "2024-10-03T06:38:55.517520+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "automation.cameras_on",
              "state": "on",
              "attributes": {
                "id": "1727879927210",
                "last_triggered": "2024-10-02T17:00:00.318647+00:00",
                "mode": "single",
                "current": 0,
                "friendly_name": "Turn on Privacy Mode"
              },
              "last_changed": "2024-10-03T06:18:21.262471+00:00",
              "last_reported": "2024-10-03T06:18:21.262471+00:00",
              "last_updated": "2024-10-03T06:18:21.262471+00:00",
              "context": {
                "id": "01J98GF26E3ED0820YJ0JVTCJY",
                "parent_id": null,
                "user_id": "2581b06774ae4454b92d26ebf0d627cb"
              }
            },
            "trigger": {
              "id": "0",
              "idx": "0",
              "alias": null,
              "platform": "state",
              "entity_id": "person.derek_graham",
              "from_state": {
                "entity_id": "person.derek_graham",
                "state": "home",
                "attributes": {
                  "editable": true,
                  "id": "derek_graham",
                  "device_trackers": [
                    "device_tracker.dereks_iphone_15_pro",
                    "device_tracker.ipad"
                  ],
                  "latitude": 41.97347069315663,
                  "longitude": -87.65208377632348,
                  "gps_accuracy": 20,
                  "source": "device_tracker.ipad",
                  "user_id": "2581b06774ae4454b92d26ebf0d627cb",
                  "friendly_name": "Derek Graham"
                },
                "last_changed": "2024-10-03T06:17:55.839639+00:00",
                "last_reported": "2024-10-03T06:30:42.804171+00:00",
                "last_updated": "2024-10-03T06:30:42.804171+00:00",
                "context": {
                  "id": "01J98H5PBMKHFEXWF7KSK1G89Y",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "to_state": {
                "entity_id": "person.derek_graham",
                "state": "home",
                "attributes": {
                  "editable": true,
                  "id": "derek_graham",
                  "device_trackers": [
                    "device_tracker.dereks_iphone_15_pro",
                    "device_tracker.ipad"
                  ],
                  "latitude": 41.97351237574414,
                  "longitude": -87.65212262430386,
                  "gps_accuracy": 6,
                  "source": "device_tracker.dereks_iphone_15_pro",
                  "user_id": "2581b06774ae4454b92d26ebf0d627cb",
                  "friendly_name": "Derek Graham"
                },
                "last_changed": "2024-10-03T06:17:55.839639+00:00",
                "last_reported": "2024-10-03T06:38:55.517317+00:00",
                "last_updated": "2024-10-03T06:38:55.517317+00:00",
                "context": {
                  "id": "01J98HMQGX5VKWJJKGDTC4GCQA",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "for": null,
              "attribute": null,
              "description": "state of person.derek_graham"
            }
          }
        }
      ],
      "condition/0": [
        {
          "path": "condition/0",
          "timestamp": "2024-10-03T06:38:55.517542+00:00",
          "result": {
            "result": true
          }
        }
      ],
      "condition/0/entity_id/0": [
        {
          "path": "condition/0/entity_id/0",
          "timestamp": "2024-10-03T06:38:55.517558+00:00",
          "result": {
            "result": true,
            "state": "home",
            "wanted_state": "home"
          }
        }
      ],
      "condition/0/entity_id/1": [
        {
          "path": "condition/0/entity_id/1",
          "timestamp": "2024-10-03T06:38:55.517586+00:00",
          "result": {
            "result": true,
            "state": "home",
            "wanted_state": "home"
          }
        }
      ],
      "condition/1": [
        {
          "path": "condition/1",
          "timestamp": "2024-10-03T06:38:55.517616+00:00",
          "result": {
            "after": {
              "__type": "<class 'datetime.time'>",
              "isoformat": "11:59:59"
            },
            "now_time": {
              "__type": "<class 'datetime.time'>",
              "isoformat": "01:38:55.517625"
            },
            "before": {
              "__type": "<class 'datetime.time'>",
              "isoformat": "13:00:00"
            },
            "result": false
          }
        }
      ]
    },
    "config": {
      "id": "1727879927210",
      "alias": "Turn on Privacy Mode",
      "description": "Turns on Privacy Mode for interior cameras",
      "trigger": [
        {
          "platform": "state",
          "entity_id": [
            "person.derek_graham",
            "person.maria"
          ],
          "enabled": true
        }
      ],
      "condition": [
        {
          "condition": "state",
          "entity_id": [
            "person.derek_graham",
            "person.maria"
          ],
          "state": "home",
          "match": "any"
        },
        {
          "condition": "time",
          "after": "11:59:59",
          "before": "13:00:00"
        }
      ],
      "action": [
        {
          "action": "switch.turn_on",
          "target": {
            "entity_id": [
              "switch.alternate_living_room_view_privacy",
              "switch.hallway_privacy",
              "switch.living_room_view_privacy"
            ]
          },
          "data": {}
        }
      ]
    },
    "blueprint_inputs": null,
    "context": {
      "id": "01J98HMQGXT7G60XQVQTGCQ9K2",
      "parent_id": "01J98HMQGX5VKWJJKGDTC4GCQA",
      "user_id": null
    }
  },
  "logbookEntries": []
}

All I went it to do is enable the privacy switches when either of us are home between 12 am to 1 pm
And privacy switches turned off if not home and between 1 pm and midnight

Ok, those triggers are from attributes of the person entity changing: the GPS coords in this case.

Add:

to: null

to each person trigger to avoid this.

And apologies — just realised you mean 00:00 not 12:00. The conditions will need altering: you will probably only need a single before/after.

Let me know if you’re still having problems and I’ll have a look when I’m not just on a phone.