# Kitchen Heater
- platform: history_stats
  name: Kitchen Heater On Last Week
  entity_id: switch.kitchen_heater
  state: "on"
  start: >
    {{ as_timestamp(
        now().replace(hour=0).replace(minute=0).replace(second=0)
      ) - (now().weekday() + 7) * 86400
    }}
  end: >
    {{ as_timestamp(
        now().replace(hour=0).replace(minute=0).replace(second=0)
      ) - now().weekday() * 86400
    }}

- platform: history_stats
  name: Kitchen Heater On This Week
  entity_id: switch.kitchen_heater
  state: "on"
  start: >
    {{ as_timestamp(
        now().replace(hour=0).replace(minute=0).replace(second=0)
      ) - now().weekday() * 86400
    }}
  end: "{{ now() }}"

- platform: history_stats
  name: Kitchen Heater On Today
  entity_id: switch.kitchen_heater
  state: "on"
  start: >
    {{ now().replace(hour=0).replace(minute=0).replace(second=0) }}
  end: "{{ now() }}"

- platform: history_stats
  name: Recent Motion
  entity_id: binary_sensor.house_motion
  state: "on"
  end: "{{ now() }}"
  duration:
    minutes: 30

# Kitchen Heater
- platform: history_stats
  name: Kitchen Heater On Last Week
  entity_id: switch.kitchen_heater
  state: "on"
  start: >
    {{ as_timestamp(
        now().replace(hour=0).replace(minute=0).replace(second=0)
      ) - (now().weekday() + 7) * 86400
    }}
  end: >
    {{ as_timestamp(
        now().replace(hour=0).replace(minute=0).replace(second=0)
      ) - now().weekday() * 86400
    }}

- platform: history_stats
  name: Kitchen Heater On This Week
  entity_id: switch.kitchen_heater
  state: "on"
  start: >
    {{ as_timestamp(
        now().replace(hour=0).replace(minute=0).replace(second=0)
      ) - now().weekday() * 86400
    }}
  end: "{{ now() }}"

- platform: history_stats
  name: Kitchen Heater On Today
  entity_id: switch.kitchen_heater
  state: "on"
  start: >
    {{ now().replace(hour=0).replace(minute=0).replace(second=0) }}
  end: "{{ now() }}"

- platform: history_stats
  name: Recent Motion
  entity_id: binary_sensor.house_motion
  state: "on"
  end: "{{ now() }}"
  type: count
  duration:
    minutes: 30

Tweak to recent motion sensor
Tweak to recent motion sensor
