Skip to main content
Tutorials

Home Assistant Automation Blueprints: Create and Share Automations

Learn to create Automation Blueprints in Home Assistant for reuse and sharing with the community

SmileX

SmileX

Founder & CEO

1 min read
Home Assistant Automation Blueprints: Create and Share Automations

Automation Blueprints คืออะไร?

Blueprints เป็นเทมเพลตสำหรับ Automations ที่สามารถนำกลับมาใช้ใหม่ได้ โดยกำหนดตัวแปรที่สามารถปรับแต่งได้

การสร้าง Blueprint พื้นฐาน

Blueprint YAML Structure

blueprint:
name: Motion-Activated Light
description: Turn on a light when motion is detected.
domain: automation
input:
motion_entity:
name: Motion Sensor
selector:
entity:
domain: binary_sensor
device_class: motion
light_target:
name: Light
selector:
target:
entity:
domain: light
no_motion_wait:
name: Wait time
default: 120
selector:
number:
min: 0
max: 3600
unit_of_measurement: seconds
trigger:
platform: state
entity_id: !input motion_entity
from: "off"
to: "on"
action:
- service: light.turn_on
target: !input light_target
- wait_for_trigger:
platform: state
entity_id: !input motion_entity
from: "on"
to: "off"
- delay: !input no_motion_wait
- service: light.turn_off
target: !input light_target

การใช้งาน Blueprint

1. Import Blueprint จาก Community

# ใน automation ของคุณ
automation:
- use_blueprint:
path: my_blueprints/motion_light.yaml
input:
motion_entity: binary_sensor.living_room_motion
light_target:
entity_id: light.living_room
no_motion_wait: 300

2. นำเข้าจาก GitHub

automation:
- use_blueprint:
url: https://github.com/home-assistant/core/blob/master/homeassistant/components/automation/blueprints/motion_light.yaml
input:
motion_entity: binary_sensor.hall_motion
light_target:
entity_id: light.hall

Advanced Blueprint ตัวอย่าง

Presence-Based Climate Control

blueprint:
name: Presence-Based Climate
description: Adjust climate based on presence and time of day.
domain: automation
input:
presence_entity:
name: Presence Sensor
selector:
entity:
domain: binary_sensor
device_class: presence
climate_entity:
name: Climate Control
selector:
entity:
domain: climate
home_temp:
name: Home Temperature
default: 24
selector:
number:
min: 16
max: 30
unit_of_measurement: °C
away_temp:
name: Away Temperature
default: 28
selector:
number:
min: 16
max: 30
unit_of_measurement: °C
trigger:
- platform: state
entity_id: !input presence_entity
action:
- service: climate.set_temperature
target:
entity_id: !input climate_entity
data:
temperature: >
{% if trigger.to_state.state == 'on' %}
{{ !input home_temp }}
{% else %}
{{ !input away_temp }}
{% endif %}

บทสรุป

Automation Blueprints ช่วยให้สามารถสร้าง Automations ที่ยืดหยุ่นและนำกลับมาใช้ใหม่ได้ ทำให้การจัดการ Smart Home มีประสิทธิภาพมากขึ้น

Share:
SmileX

About the Author

SmileX

Founder & CEO

Founder of RACKSYNC with 14+ years of experience in IoT, Cloud Infrastructure, and Smart Home solutions.