Har fixat lite scripts nu när man flyttat. Detta script
Slår på taklamporna i sovrummet när man går in i sovrummet och stänger av efter 3 minuter mellan 08-21 (ändrade från 06 till 08 nu)
Kod:
# ------------------------------------------------------------------------------------------ #
# Lines starting with “#” are comments and will be ignored by the automation.
# Indentation determines hierarchy within the script.
# Visit g.co/home/script-editor-docs for full documentation.
# ------------------------------------------------------------------------------------------ #
metadata:
name: Lampor i sovrummet # Choose a short name that summarizes important starters and actions, like “Sunset lights”.
description: Tänder lamporna i sovrummet # Write a detailed description that includes everything the automation does, like “At sunset, on weekdays, close blinds, turn on lights to 50%, and play the sunset playlist on certain speakers.”
automations:
# “starters” and “actions” are required; “conditions” are optional.
# Use Ctrl + Space to see autocomplete suggestions.
# ---- STARTERS ---- #
# Starters describe events that will start the automation.
# To add more than one starter, duplicate the "- type" section under "starters".
# If you add multiple starter events, any one of them happening will start the automation.
starters:
- type: device.state.OccupancySensing # For devices that can detect occupancy, whether through PIR, ultrasonic, or physical contact sensing.
state: occupancy
# Whether the device senses occupancy. [available operators: is, isNot]
is: OCCUPIED
device: Aqara Motion Sensor (S) - Sovrummet
# ---- CONDITIONS ---- #
# Conditions are optional. Delete this section if it’s empty.
# Conditions will prevent an automation from starting if the conditions aren’t met.
# See g.co/home/script-editor-docs for documentation about how to use logical operators like “and”, “or”, and “not”.
condition:
type: time.between
# Optional. Accepts either clock time (10:00:00 AM, with seconds optional, or in a 24 hour format), or 'sunrise' or 'sunset', with an optional offset ('sunrise+10m', for instance)
before: 21:00 # HH:MM (24 hours format). Adjust time as needed
# Optional. Accepts either clock time (10:00:00 AM, with seconds optional, or in a 24 hour format), or 'sunrise' or 'sunset', with an optional offset ('sunrise+10m', for instance)
after: 08:00 # HH:MM (24 hours format). Adjust time as needed
# ---- ACTIONS ---- #
# Actions will start when a starter event takes place and all conditions are met.
# Actions will start in the order they appear in the script and with any delay specified.
# To add more than one action, duplicate the "- type" section under "actions".
actions:
- type: device.command.BrightnessAbsolute # Adjust device absolute brightness. When brightness is set to any value greater than 0, if the device is off, it powers on, and the [`OnOffState.state`](./on_off_state) changes to reflect that the device is on. Likewise, when brightness is set to 0, the device powers off and the [`OnOffState.state`](./on_off_state) changes accordingly.
# New brightness percentage.
brightness: 100
devices:
- Mi Smart (1) - Sovrummet
- Mi Smart (2) - Sovrummet
- type: time.delay
for: 3min
- type: device.command.OnOff
devices:
- Mi Smart (1) - Sovrummet
- Mi Smart (2) - Sovrummet
on: false
Sedan har jag en
Som slår på 1 lampa på kvällen och morgonen på 50% istället för 2 lampor på 100% när man troligtvis ska vara i sängen.
Kod:
metadata:
name: Lampor i sovrummet (2)
description: Tänder lamporna i sovrummet vid läggdags
automations:
- starters:
- type: device.state.OccupancySensing # For devices that can detect occupancy, whether through PIR, ultrasonic, or physical contact sensing.
device: Aqara Motion Sensor (S) - Sovrummet
state: occupancy
is: OCCUPIED
condition:
type: and
# "AND" together two or more conditionals
# Tänder bara 1 lampa på morgonen och kvällen när man troligtvis är i sängen
conditions:
- type: time.between
# Optional. Accepts either clock time (10:00:00 AM, with seconds optional, or in a 24 hour format), or 'sunrise' or 'sunset', with an optional offset ('sunrise+10m', for instance)
before: 23:00 # HH:MM (24 hours format). Adjust time as needed
# Optional. Accepts either clock time (10:00:00 AM, with seconds optional, or in a 24 hour format), or 'sunrise' or 'sunset', with an optional offset ('sunrise+10m', for instance)
after: 21:00 # HH:MM (24 hours format). Adjust time as needed
- type: time.between
# Optional. Accepts either clock time (10:00:00 AM, with seconds optional, or in a 24 hour format), or 'sunrise' or 'sunset', with an optional offset ('sunrise+10m', for instance)
before: 08:00 # HH:MM (24 hours format). Adjust time as needed
# Optional. Accepts either clock time (10:00:00 AM, with seconds optional, or in a 24 hour format), or 'sunrise' or 'sunset', with an optional offset ('sunrise+10m', for instance)
after: 06:00 # HH:MM (24 hours format). Adjust time as needed
actions:
- type: device.command.BrightnessAbsolute # Adjust device absolute brightness. When brightness is set to any value greater than 0, if the device is off, it powers on, and the [`OnOffState.state`](./on_off_state) changes to reflect that the device is on. Likewise, when brightness is set to 0, the device powers off and the [`OnOffState.state`](./on_off_state) changes accordingly.
# New brightness percentage.
brightness: 50
devices: Mi Smart (1) - Sovrummet