Berikut ini adalah contoh Automation di Home Assistant yang akan memutar Notifikasi suara yang menunjukan Jam (waktu), seperti layaknya Cuckoo Clock

Persiapan

  1. Pertama anda perlu menambahkan kode dibawah ini di file configuration.yaml
    fungsinya adalah membuat sensor waktu (time)

    sensor:
      - platform: time_date
        display_options:
          - 'time'
          - 'date'
          - 'date_time'
          - 'date_time_iso'
          - 'time_date'
          - 'time_utc'
          - 'beat'
  2. Menambahkan tts google translate say pada file configuration.yaml
    tts:
      - platform: google_translate
        language: id

Setelah di tambahkan dan simpan, jangan lupa untuk me-restart Home Assistant, namun sebelumnya sebaiknya cek terlebih dahulu file configuration apakah terdapat error atau tidak.

Open your Home Assistant instance and show your server controls.

Automation menggunakan platform template

Selanjutnya tambahkan automation dengan trigger platform template dengan menyamakan waktu sensor.time dengan nilai waktu yang kita tentukan. tentunya bisa anda atur sendiri pada jam berapa saja automation akan berjalan.

alias: Notifikasi Pesan Suara tiap jam Google Home Speaker
description: ''
mode: single
trigger:
  - platform: template
    value_template: '{{ states("sensor.time") == "00:00" }}'
  - platform: template
    value_template: '{{ states("sensor.time") == "01:00" }}'
  - platform: template
    value_template: '{{ states("sensor.time") == "02:00" }}'
  - platform: template
    value_template: '{{ states("sensor.time") == "03:00" }}'
  - platform: template
    value_template: '{{ states("sensor.time") == "04:00" }}'
  - platform: template
    value_template: '{{ states("sensor.time") == "05:00" }}'
  - platform: template
    value_template: '{{ states("sensor.time") == "06:00" }}'
  - platform: template
    value_template: '{{ states("sensor.time") == "07:00" }}'
  - platform: template
    value_template: '{{ states("sensor.time") == "08:00" }}'
  - platform: template
    value_template: '{{ states("sensor.time") == "09:00" }}'
  - platform: template
    value_template: '{{ states("sensor.time") == "10:00" }}'
  - platform: template
    value_template: '{{ states("sensor.time") == "11:00" }}'
  - platform: template
    value_template: '{{ states("sensor.time") == "12:00" }}'
  - platform: template
    value_template: '{{ states("sensor.time") == "13:00" }}'
  - platform: template
    value_template: '{{ states("sensor.time") == "14:00" }}'
  - platform: template
    value_template: '{{ states("sensor.time") == "15:00" }}'
  - platform: template
    value_template: '{{ states("sensor.time") == "16:00" }}'
  - platform: template
    value_template: '{{ states("sensor.time") == "17:00" }}'
  - platform: template
    value_template: '{{ states("sensor.time") == "18:00" }}'
  - platform: template
    value_template: '{{ states("sensor.time") == "19:00" }}'
  - platform: template
    value_template: '{{ states("sensor.time") == "20:00" }}'
  - platform: template
    value_template: '{{ states("sensor.time") == "21:00" }}'
  - platform: template
    value_template: '{{ states("sensor.time") == "22:00" }}'
  - platform: template
    value_template: '{{ states("sensor.time") == "23:00" }}'
condition: []
action:
  - service: tts.google_translate_say
    data:
      entity_id: media_player.family_room
      message: >-
        Sekarang jam {{ states("sensor.time")  }}
      language: id

Penjelasan :
Trigger dari automation ini menggunakan platform template dengan mengambil value sensor.time dan menyamakan nya dengan waktu saat ini, kemudian untuk action nya menggunakan service tts (text to speech) dari Google Translate

Automation menggunakan time_pattern

Jika anda ingin membuatnya berjalan otomatis pada pola waktu tertentu, misalkan tiap jam atau tiap berapa menit sekali, maka anda bisa gunakan automation dibawah ini yang akan mentrigger dengan platform time_pattern. dengan mengisi /1 artinya alarm notification akan berjalan tiap jam.

sedangkan condition juga bisa anda tentukan, misalnya hanya akan berbunyi dari jam A sampai dengan jam B

Untuk pemanis anda bisa tambahkan suara chime / notification sound dengan menambahkan action play media file mp3 di local folder. contoh code nya seperti contoh dibawah ini :

alias: Info Jam
description: ''
trigger:
  - platform: time_pattern
    hours: /1
condition:
  - condition: time
    after: '07:00:00'
    before: '18:00:00'
action:
  - service: media_player.play_media
    data:
      media_content_id: media-source://media_source/local/chime_carillon.mp3
      media_content_type: audio/mp3
    target:
      entity_id: media_player.family_room
  - delay:
      hours: 0
      minutes: 0
      seconds: 6
      milliseconds: 0
  - service: tts.google_translate_say
    data:
      entity_id: media_player.family_room
      message: Sekarang jam {{ states("sensor.time") }}
      language: id
mode: queued
max: 10

File Mp3
Download Mp3 File


0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *