# Home Assistant オートメーションルール

**URL:** https://forum.ficusonline.com/t/topic/485
**Category:** Automation
**Created:** [2023 年 5 月 30 日午後 1:07 UTC](https://forum.ficusonline.com/t/topic/485 "2023-05-30T13:07:37Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2023 年 5 月 30 日午後 1:07 UTC](https://forum.ficusonline.com/t/topic/485/1 "2023-05-30T13:07:37Z")

</div>

## State Trigger

> **[State trigger - Automation Trigger](https://www.home-assistant.io/docs/automation/trigger/#state-trigger)**
>
> Triggers are what starts the processing of an automationAutomations in Home Assistant allow you to automatically respond to things that happen in and around your home. \[Learn more\] rule. When any of the automation’s triggers becomes true (trigger...

各デバイスはインターネット経由でゲートウェイへ接続できるため、設置場所はインターネット接続環境があればどこでも可。以下オートメーションルールを幾つか例示しますが、時間・場所・センサデバイスのステータスなどの条件とアクションとの組み合わせが多岐に渡るため、多様なルールを設定できます。

### オートメーションルール その１

- トリガー：LEDスポットライトを点灯、点灯状態が3秒以上続いた場合
- アクション：別のLEDがフラッシュ点灯、プレーヤーから警告音を再生

LED照明のスイッチを緊急時のボタンとして使用。スイッチが押されると別のLED照明がフラッシュ点灯しゲートウェイから警告音が流れます（ゲートウェイとデバイスが同じ屋内に設置されている場合を想定したルール）。

`config/automations.yaml`

```auto
- id: 'xxxxxxxxxxxxxxx'
  alias: flash+play_radio
  description: ''
  trigger:
  - platform: state
    entity_id:
    - light.spot_light1
    from: 'off'
    to: 'on'
    for:
      hours: 0
      minutes: 0
      seconds: 3
  condition: []
  action:
  - data:
      effect: flash
    service: light.turn_on
    target:
      entity_id:
      - light.spot_light2
  - service: shell_command.play_radio
    data: {}
  mode: single

```

ルール設定はHome Assistantの設定画面から容易に行えます。

**設定画面**

 ![Screenshot from 2023-05-30 22-09-20](https://forum.ficusonline.com/uploads/default/original/2X/e/e1abd807a2fb1c2230f79e68a6a6a17b3300a34c.png)

**オートメーションルールリスト**

 ![Screenshot from 2023-05-30 22-09-40](https://forum.ficusonline.com/uploads/default/original/2X/f/fe6594a2ee0930965af378220bf4ec1af8411ae5.png)

**ルール設定画面**

 ![Screenshot from 2023-05-30 22-15-44](https://forum.ficusonline.com/uploads/default/original/2X/2/2e3683ef3c0ed654ae93263a92213b3f2303b981.png)

### オートメーションルール その２

- トリガー：LEDスポットライトを点灯、点灯状態が3秒以上続いた場合
- アクション：別のLEDがフラッシュ点灯、IP電話へコール

LED照明のスイッチを緊急時のボタンとして使用。スイッチが押されると別のLED照明がフラッシュ点灯しLinphoneのSIPアドレス宛にIP電話がかかってきます（例えば一人暮らしの高齢者宅にこのデバイスを設置することで、緊急時にスイッチを押すだけで第三者に異常を知らせることが出来ます）。

 ![ficus-home.duckdns.org_8123_config_automation_edit_1685448404826(iPad Air)](https://forum.ficusonline.com/uploads/default/original/2X/5/565fca1fbd0b999e50a6a1e0f1c2c996f1d1c12a.png)

### オートメーションルール その３

指定エリアに入った時点でお知らせメールを送信。子供が無事に学校などのエリアに到着またはエリアから出発したかどうかを確認するためのルール。

OwnTracksをインストールしたデバイスとHome Assistant登録ユーザを紐付けることにより、Home Assistantで登録した指定エリアに入った・またはそこから離れた時点で第三者にメールが送信されます。

 ![Screenshot from 2023-06-12 13-52-27](https://forum.ficusonline.com/uploads/default/original/2X/d/d2fe1cdb25d2ddc5432ec8487e1ddbccc2e73f4a.png)

### オートメーションルール その４

侵入者・盗難対策  
レーダセンサデバイスや傾きセンサが反応した際に、LED照明をONにし、第三者に電話をかけて知らせます。侵入者対策、オートバイなどの盗難対策として利用。

 ![Screenshot from 2023-06-12 13-55-57](https://forum.ficusonline.com/uploads/default/original/2X/2/2726620b469f17d50c9736c643a5ceac5d7417a2.png)
