Adding AI to Your Home Assistant Notifications

Adding AI to Your Home Assistant Notifications

In the past, I relied heavily on WhatsApp to receive notifications from my smart home setup in Home Assistant. These notifications ranged from simple updates, like a device being turned on or someone ringing the doorbell, to more complex information, such as detailed reports on how much I spent overnight charging my electric car. Over time, however, I noticed that the messages were becoming monotonous. Receiving the same “The washing machine was turned on” message repeatedly can lose its charm quickly. To make these updates more engaging and add some creative flair, I decided to integrate OpenAI into the process. This guide will show you how to do the same—creating dynamic, entertaining notifications that stand out. With a bit of tweaking to the OpenAI prompt, you can even craft notifications that are funny, sarcastic, or delivered in rhymes!

In this guide, I’ll show you how to combine WhatsApp with OpenAI for smarter, more personalized notifications. While I’m using WhatsApp, you can adapt the concept to other messaging methods as well.

Requirements

  1. WhatsApp addon for notifications (setup guide: Integrating WhatsApp into Home Assistant)
  2. OpenAI integration (official guide: OpenAI Conversation Integration)

Step 1: Install WhatsApp Addon

Follow my detailed guide to set up WhatsApp notifications in Home Assistant: Integrating WhatsApp into Home Assistant.

Step 2: Install OpenAI Integration

Next, set up the OpenAI integration by following the official instructions here: OpenAI Conversation Integration.

Step 3: Create a New Script

Once you have both integrations installed, it’s time to create the script that combines them.

  1. Go to Settings > Scripts > Add a new script.
  2. Copy and paste the following YAML code into your script editor:
alias: Notify Whatsapp + AI
sequence:
  - alias: Conversation Agent Notification Text
    data:
      text: >-
        The following is information that is about to be sent to our family's
        WhatsApp group.  Rephrase it while retaining all the information
        details, do not remove any of the provided details, only change the
        phrasing of the paragraph. Your response will be taken and sent as a
        Whatsapp message so you can include Whatsapp-style formatting and emojis
        --- `{{message}}`
      agent_id: dc58a333a9bd52c135833cd2fa58e805
      conversation_id: "1"
    response_variable: agent
    action: conversation.process
  - alias: Send notification
    data:
      clientId: default
      to: [your phone number]
      body:
        text: "{{ agent.response.speech.plain.speech }}"
    enabled: true
    action: whatsapp.send_message
fields:
  message:
    selector:
      text:
        multiline: true
    name: Message
    required: true
    description: The message to send
description: Notify whatsapp group + ChatGPT integration
icon: mdi:message-bulleted

Step 4: Send AI-Powered Notifications

To send a notification, call the script with the message you want. Here’s an example:

action: script.notify_whatsapp_ai
metadata: {}
data:
  message: Dryer is done, don't forget to take the clothes out.

This will send the message through OpenAI for beautifying and formatting before delivering it to WhatsApp. The final notification could include WhatsApp-style formatting and even emojis, making your messages more engaging.

Summary

By combining WhatsApp and OpenAI with Home Assistant, you can create smarter notifications that are both functional and pleasant to receive. Whether you’re reminding your family to take out the laundry or notifying them about security updates, this integration adds a touch of AI-powered flair to your smart home.

Ready to make your notifications smarter? Get started with the steps above and enjoy a more personalized smart home experience!


Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply