Enhancing REST Service Integration in Home Automation

I recently embarked on integrating a REST service into my home automation setup, and it’s been an enlightening journey! After successfully installing and configuring the Docker WAHA on my Unraid server, I set up the REST command in my Home Assistant configuration. The setup allows me to send WhatsApp messages through an automation, which is pretty cool. Here’s a snippet of how I configured it:

yaml
rest_command:
whatsappsend:
url: http://192.168.178.200:3000/api/sendText
method: POST
headers:
accept: “application/json”
payload: “{ “chatId”: “{{ nummer }}”, “text”: “{{ nachricht }}”, “session”: “{{ sitzung | default(‘default’) }}” }”
content_type: ‘application/json’

Testing it out, I was able to send messages through an automation, which worked like a charm. But here’s where things got interesting—I wanted to make the parameter input more user-friendly, similar to the interface shown in the image below.

User-Friendly REST Parameter Input

The challenge was figuring out how to create a dialog-based input for the REST parameters (like number and message). After some research and experimentation, I discovered that using a combination of input_text and input_select entities could achieve this. Here’s how I structured it:

  1. Input Text for Message: I created an input_text entity where users can type their message.
    yaml
    input_text:
    notification_message:
    name: Notification Message
    initial: “”

  2. Input Select for Recipient: I set up an input_select entity to choose the recipient from a predefined list.
    yaml
    input_select:
    notification_recipient:
    name: Notification Recipient
    options:
    - +1234567890
    - +0987654321
    initial: +1234567890

  3. Automation to Trigger the REST Command: Finally, I created an automation that uses the selected recipient and the entered message to trigger the REST command.
    yaml
    automation:

    • alias: Send WhatsApp Notification
      trigger:
      • platform: event
        event_type: send_notification
        action:
      • service: rest_command.whatsappsend
        data_template:
        nummer: “{{ states.input_select.notification_recipient.state }}”
        nachricht: “{{ states.input_text.notification_message.state }}”
        sitzung: default

This setup allows me to send notifications through a simple dialog interface, making the automation much more user-friendly. It’s been a great way to streamline my home automation processes!

If anyone has tips or alternative methods for achieving this, I’d love to hear them. Happy automating! :rocket: