Integrasi Home Assistant - Peringatan Rumah Pintar

Hubungkan Home Assistant ke Echobell untuk peringatan rumah pintar secara instan: keamanan, gerakan, suhu, dan peristiwa otomasi sebagai push atau panggilan telepon.


Home Assistant adalah platform otomasi rumah open-source yang tangguh dan mengutamakan kendali lokal serta privasi. Dengan mengintegrasikan Echobell ke Home Assistant, Anda bisa menerima notifikasi instan bahkan panggilan telepon saat terjadi peristiwa penting di rumah pintar Anda—entah itu peringatan keamanan, suhu yang melewati ambang batas, atau pemicu otomasi.

Panduan ini menuntun Anda menyiapkan Echobell agar menerima notifikasi dari otomasi Home Assistant Anda memakai webhook atau layanan RESTful Notify.

Prasyarat

Sebelum mulai, pastikan Anda punya:

  • Aplikasi Echobell / Google Play yang sudah terpasang di perangkat seluler Anda
  • Saluran Echobell yang aktif (buat satu di aplikasi kalau belum punya)
  • Instance Home Assistant yang sedang berjalan (disarankan versi 2023.1 atau lebih baru)
  • Akses ke konfigurasi Home Assistant Anda

Metode 1: Memakai Pemicu Webhook (Disarankan)

Metode webhook adalah pendekatan yang paling fleksibel karena memungkinkan Anda mengirim data khusus dan memakai variabel templat di notifikasi Anda.

Dapatkan URL Webhook Echobell Anda

  1. Buka aplikasi Echobell lalu masuk ke saluran Anda
  2. Ketuk salurannya untuk melihat detail
  3. Temukan URL Webhook di bagian Pemicu
  4. Salin URL-nya—bentuknya kira-kira seperti ini: https://hook.echobell.one/t/<channel-token>

Buat Otomasi Home Assistant

Di Home Assistant, Anda bisa memicu notifikasi Echobell memakai layanan rest_command. Pertama, tambahkan REST command ke configuration.yaml Anda:

rest_command:
  echobell_notify:
    url: "https://hook.echobell.one/t/<channel-token>"
    method: POST
    content_type: "application/json"
    payload: '{"title": "{{ title }}", "message": "{{ message }}"}'

Ganti YOUR_TOKEN dengan token webhook Echobell Anda yang sebenarnya.

Setelah menambahkannya, mulai ulang Home Assistant untuk memuat konfigurasi barunya.

Gunakan di Otomasi

Sekarang Anda bisa memanggil layanan ini dari otomasi mana pun. Berikut contoh yang memberi tahu Anda saat sebuah pintu terbuka:

automation:
  - alias: "Door Open Alert"
    trigger:
      - platform: state
        entity_id: binary_sensor.front_door
        to: "on"
    action:
      - service: rest_command.echobell_notify
        data:
          title: "Security Alert"
          message: "Front door opened at {{ now().strftime('%H:%M') }}"

Konfigurasikan Templat Notifikasi

Di pengaturan saluran Echobell Anda, konfigurasikan templat notifikasi agar menampilkan data webhook:

  • Templat judul: {{title}}
  • Templat isi: {{message}}

Sekarang saat otomasi itu terpicu, Anda akan menerima notifikasi dengan judul dan pesan khusus tersebut.

Metode 2: Memakai Platform RESTful Notify

Untuk pendekatan yang lebih menyatu, Anda bisa menyiapkan Echobell sebagai layanan notify di Home Assistant.

Konfigurasi

Tambahkan berikut ini ke configuration.yaml Anda:

notify:
  - name: echobell
    platform: rest
    resource: https://hook.echobell.one/t/<channel-token>
    method: POST_JSON
    data:
      title: "{{ title }}"
      message: "{{ message }}"

Ganti YOUR_TOKEN dengan token webhook Echobell Anda, lalu mulai ulang Home Assistant.

Memakai Layanan Notify

Sekarang Anda bisa memakai Echobell seperti layanan notify lainnya:

automation:
  - alias: "Low Battery Alert"
    trigger:
      - platform: numeric_state
        entity_id: sensor.phone_battery
        below: 20
    action:
      - service: notify.echobell
        data:
          title: "Low Battery Warning"
          message: "Phone battery is at {{ states('sensor.phone_battery') }}%"

Kasus Penggunaan Lanjutan

Pemantauan Suhu dengan Peringatan Kritis

Gunakan jenis notifikasi untuk mengirim peringatan suhu yang kritis sebagai panggilan:

rest_command:
  echobell_critical:
    url: "https://hook.echobell.one/t/<channel-token>"
    method: POST
    content_type: "application/json"
    payload: '{"temperature": "{{ temperature }}", "location": "{{ location }}", "severity": "critical"}'

Di saluran Echobell Anda, setel jenis notifikasi ke "Panggilan" lalu pakai templat ini:

  • Judul: Critical Temperature Alert
  • Isi: {{location}} temperature is {{temperature}}°C - Immediate attention required!

Integrasi Sistem Keamanan

Siapkan pemantauan keamanan yang menyeluruh:

automation:
  - alias: "Security Breach Detection"
    trigger:
      - platform: state
        entity_id:
          - binary_sensor.motion_detector_1
          - binary_sensor.motion_detector_2
          - binary_sensor.window_sensor
        to: "on"
    condition:
      - condition: state
        entity_id: alarm_control_panel.home_alarm
        state: "armed_away"
    action:
      - service: rest_command.echobell_notify
        data:
          title: "🚨 Security Alert"
          message: "{{ trigger.to_state.attributes.friendly_name }} detected activity while system armed"
          sensor: "{{ trigger.entity_id }}"
          timestamp: "{{ now().isoformat() }}"

Notifikasi Peralatan Pintar

Pantau siklus kerja peralatan dan dapatkan pemberitahuan saat siklusnya selesai:

automation:
  - alias: "Washing Machine Complete"
    trigger:
      - platform: state
        entity_id: sensor.washing_machine_power
        to: "0"
        for:
          minutes: 3
    action:
      - service: notify.echobell
        data:
          title: "Washing Machine Done"
          message: "Your laundry is ready to be moved to the dryer"

Pemantauan Lingkungan

Pantau kualitas udara, kelembapan, atau faktor lingkungan lainnya:

automation:
  - alias: "High CO2 Alert"
    trigger:
      - platform: numeric_state
        entity_id: sensor.living_room_co2
        above: 1000
    action:
      - service: rest_command.echobell_notify
        data:
          title: "Air Quality Warning"
          message: "CO2 level in living room is {{ states('sensor.living_room_co2') }} ppm. Consider ventilating."

Memakai Kondisi untuk Penyaringan Cerdas

Anda bisa memakai kondisi Echobell untuk menyaring notifikasi berdasarkan kriteria tertentu. Misalnya, hanya memberi tahu pada jam tertentu atau saat nilainya melewati ambang batas:

Tetapkan sebuah kondisi di saluran Echobell Anda:

severity == "critical" || (hour >= 22 || hour <= 7)

Ini hanya mengirim notifikasi kalau tingkat keparahannya kritis ATAU kalau saat itu malam hari (pukul 22.00 sampai 07.00).

Di otomasi Home Assistant Anda, sertakan data yang relevan:

action:
  - service: rest_command.echobell_notify
    data:
      title: "Temperature Alert"
      message: "Freezer temperature: {{ states('sensor.freezer_temp') }}°C"
      severity: "{% if states('sensor.freezer_temp') | float > -10 %}critical{% else %}normal{% endif %}"
      hour: "{{ now().hour }}"

Mengirim Data Sensor

Anda bisa meneruskan data sensor Home Assistant apa pun ke notifikasi Echobell Anda:

rest_command:
  echobell_sensor_update:
    url: "https://hook.echobell.one/t/<channel-token>"
    method: POST
    content_type: "application/json"
    payload: >
      {
        "sensor_name": "{{ sensor_name }}",
        "current_value": "{{ current_value }}",
        "unit": "{{ unit }}",
        "state": "{{ state }}",
        "timestamp": "{{ timestamp }}"
      }

Menangani Header HTTP

Echobell bisa mengakses header HTTP dari permintaan webhook. Ini berguna untuk autentikasi atau pelacakan:

rest_command:
  echobell_with_headers:
    url: "https://hook.echobell.one/t/<channel-token>"
    method: POST
    headers:
      X-Home-Assistant-Instance: "{{ instance_name }}"
      X-Automation-ID: "{{ automation_id }}"
    content_type: "application/json"
    payload: '{"message": "{{ message }}"}'

Di templat Echobell Anda, akses header dengan:

{{header["x-home-assistant-instance"]}}

Debugging dan Pengujian

Uji Webhook Anda

Gunakan Developer Tools → Services di Home Assistant untuk menguji konfigurasi Anda:

  1. Pilih rest_command.echobell_notify
  2. Masukkan data uji coba:
title: "Test Notification"
message: "This is a test from Home Assistant"
  1. Klik "Call Service"
  2. Periksa aplikasi Echobell Anda untuk melihat notifikasinya

Periksa Log Home Assistant

Kalau notifikasi tidak sampai, periksa log Home Assistant:

# Di Home Assistant, buka:
Settings System Logs

# Atau periksa berkas log-nya:
config/home-assistant.log

Cari kesalahan yang berkaitan dengan rest_command atau permintaan HTTP ke hook.echobell.one.

Verifikasi URL Webhook

Pastikan URL webhook Anda sudah benar:

  • URL-nya harus diawali https://hook.echobell.one/t/
  • Token-nya harus disertakan
  • Tanpa spasi atau karakter tambahan

Pertimbangan Performa

Pembatasan Frekuensi

Webhook Echobell tunduk pada pembatasan frekuensi untuk mencegah penyalahgunaan. Untuk sensor berfrekuensi tinggi:

  • Hindari memicu pada setiap pembaruan sensor
  • Pakai for di trigger untuk meredam pemicu beruntun:
trigger:
  - platform: numeric_state
    entity_id: sensor.temperature
    above: 30
    for:
      minutes: 5 # Hanya terpicu setelah 5 menit di atas ambang batas

Menggabungkan Pembaruan

Untuk beberapa peristiwa yang saling terkait, pertimbangkan menggabungkannya jadi satu notifikasi:

automation:
  - alias: "Daily Home Summary"
    trigger:
      - platform: time
        at: "09:00:00"
    action:
      - service: rest_command.echobell_notify
        data:
          title: "Morning Home Summary"
          message: >
            Temperature: {{ states('sensor.temperature') }}°C
            Humidity: {{ states('sensor.humidity') }}%
            Energy today: {{ states('sensor.daily_energy') }} kWh
            Windows open: {{ expand(states.binary_sensor) | selectattr('state', 'eq', 'on') | selectattr('attributes.device_class', 'eq', 'window') | list | count }}

Praktik Terbaik Keamanan

Lindungi URL Webhook Anda

  • Jangan pernah menaruh URL webhook di repositori publik
  • Gunakan secrets Home Assistant untuk data sensitif
  • Ganti token webhook secara berkala

Memakai secrets di configuration.yaml:

# secrets.yaml
echobell_webhook: "https://hook.echobell.one/t/<channel-token>"

# configuration.yaml
rest_command:
  echobell_notify:
    url: !secret echobell_webhook
    method: POST
    content_type: "application/json"
    payload: '{"title": "{{ title }}", "message": "{{ message }}"}'

Batasi Informasi Sensitif

Berhati-hatilah dengan data yang Anda sertakan di notifikasi:

# Bagus - Informasi umum
message: "Motion detected in living room"

# Hindari - Detail sensitif
message: "Security code: 1234, camera feed: http://..."

Mengatasi Masalah Umum

Notifikasi Tidak Sampai

  1. Periksa koneksi jaringan: Pastikan instance Home Assistant Anda bisa menjangkau internet
  2. Verifikasi URL webhook: Salin dan tempel dengan teliti, termasuk token-nya
  3. Periksa aplikasi Echobell: Pastikan Anda berlangganan saluran tersebut
  4. Tinjau log Home Assistant: Cari kesalahan HTTP atau timeout

Kesalahan Templat

Kalau templat tidak dirender dengan benar:

  1. Uji templat di Developer Tools → Template
  2. Pastikan nama variabel cocok antara Home Assistant dan Echobell
  3. Periksa salah ketik pada sintaks templat: {{variable}} bukan {{ variable}}

Otomasi Tidak Terpicu

  1. Verifikasi kondisi pemicu di Home Assistant
  2. Uji otomasinya secara manual dari Developer Tools
  3. Periksa apakah status entitas cocok dengan konfigurasi pemicu Anda
  4. Tinjau trace otomasi untuk debugging

Contoh: Penyiapan Sistem Keamanan yang Lengkap

Berikut contoh menyeluruh yang mengintegrasikan beberapa sensor keamanan:

# configuration.yaml
rest_command:
  echobell_security:
    url: !secret echobell_security_webhook
    method: POST
    content_type: "application/json"
    payload: >
      {
        "event_type": "{{ event_type }}",
        "location": "{{ location }}",
        "sensor": "{{ sensor }}",
        "timestamp": "{{ timestamp }}",
        "alarm_state": "{{ alarm_state }}"
      }

# automations.yaml
- alias: "Security Event Handler"
  trigger:
    - platform: state
      entity_id:
        - binary_sensor.front_door
        - binary_sensor.back_door
        - binary_sensor.garage_door
        - binary_sensor.motion_hallway
        - binary_sensor.motion_living_room
      to: "on"
  action:
    - service: rest_command.echobell_security
      data:
        event_type: "{{ 'door' if 'door' in trigger.entity_id else 'motion' }}"
        location: "{{ trigger.to_state.attributes.friendly_name }}"
        sensor: "{{ trigger.entity_id }}"
        timestamp: "{{ now().strftime('%Y-%m-%d %H:%M:%S') }}"
        alarm_state: "{{ states('alarm_control_panel.home_alarm') }}"

Di Echobell, setel templat Anda:

  • Judul: Security Alert: {{event_type | upper}}
  • Isi: {{location}} activated at {{timestamp}} (Alarm: {{alarm_state}})

Langkah Berikutnya

Setelah Echobell terintegrasi dengan Home Assistant:

Sumber Terkait