{
  "id": "bedroom_manual_override",
  "alias": "Bedroom manual override",
  "description": "20:00-09:00: any Upstairs setpoint change NOT made by an automation (Nest dial, app, HA UI) turns on input_boolean.bedroom_manual_override, which stops 'Bedroom night warmth' pulsing for the rest of the night. Automation writes are recognised two ways: the change has a parent context (event-triggered run), or its context matches input_text.bedroom_auto_write, which every automation that sets Upstairs stamps immediately before the write (time-triggered runs have no parent context; 2026-11-23 a 05:00 pulse was mistaken for a hand change). The step-down/ceiling in '_reset' still applies. Cleared at 09:00, or by script.bedroom_resume_auto (dashboard button). Managed from the infra repo, 2026-11-22. 2026-11-24: the override no longer stops burns (the bedroom is always watched); a hand change now sets the saved base to the hand value and zeroes input_number.bedroom_ratchet_steps.",
  "triggers": [
    {
      "trigger": "state",
      "entity_id": "climate.upstairs_nest",
      "attribute": "temperature",
      "id": "change"
    },
    {
      "trigger": "time",
      "at": "09:00:00",
      "id": "clear"
    }
  ],
  "conditions": [],
  "actions": [
    {
      "choose": [
        {
          "conditions": [
            {
              "condition": "trigger",
              "id": "clear"
            }
          ],
          "sequence": [
            {
              "action": "input_boolean.turn_off",
              "target": {
                "entity_id": "input_boolean.bedroom_manual_override"
              }
            }
          ]
        },
        {
          "conditions": [
            {
              "condition": "trigger",
              "id": "change"
            },
            {
              "condition": "time",
              "after": "20:00:00",
              "before": "09:00:00"
            },
            {
              "condition": "template",
              "value_template": "{% set f = trigger.from_state %}{% set t = trigger.to_state %}{% set aw = states.input_text.bedroom_auto_write %}{{ t.context.parent_id is none and (aw is none or t.context.id != aw.context.id) and f is not none and f.state not in ['unavailable','unknown'] and t.state not in ['unavailable','unknown'] and f.attributes.temperature is not none and t.attributes.temperature is not none and f.attributes.temperature != t.attributes.temperature }}"
            }
          ],
          "sequence": [
            {
              "action": "input_boolean.turn_on",
              "target": {
                "entity_id": "input_boolean.bedroom_manual_override"
              }
            },
            {
              "action": "input_number.set_value",
              "target": {
                "entity_id": "input_number.bedroom_ratchet_steps"
              },
              "data": {
                "value": 0
              }
            },
            {
              "action": "input_number.set_value",
              "target": {
                "entity_id": "input_number.bedroom_pre_boost_setpoint"
              },
              "data": {
                "value": "{{ trigger.to_state.attributes.temperature }}"
              }
            },
            {
              "action": "logbook.log",
              "data": {
                "name": "Bedroom night warmth",
                "entity_id": "climate.upstairs_nest",
                "message": "Upstairs set by hand to {{ trigger.to_state.attributes.temperature }}F: kept as the night setting; the bedroom is still watched (burns restore to this)"
              }
            }
          ]
        }
      ]
    }
  ],
  "mode": "queued"
}
