AI Robot

Integrating WhatsApp into Home Assistant – Part 2: Messaging Groups

In a previous post (Part 1: Setup and Notifications), we explored how to set up a WhatsApp bot in Home Assistant and send notifications to WhatsApp from Home Assistant. Now, let’s take it a step further by adding this bot to your family group, enabling everyone in the group to receive notifications.

Step 1: Adding the Bot to Your Family Group

First, add the WhatsApp bot contact to your family group, just as you would add any other contact. You’ll need to approve this addition through the cloned WhatsApp app or from your secondary phone.

Step 2: Capture the Group’s Identifier

Next, navigate to Home Assistant -> Developer Tools -> Events. Under the “Listen to events” section, type new_whatsapp_message and click “Start Listening.”

Now, send a message to the family group from your own phone (your regular phone, not the cloned one). Any message will do. You’ll see an event captured in Home Assistant indicating that a new WhatsApp message has been received. Stop listening to the event.

In the event details, locate the “remoteJid” value. This will include an 18-digit number followed by @g.us. Save this number for the next step.

Step 3: Automate Group Notifications

To send notifications to the entire group, use the following automation script:

alias: Send notification
data:
  clientId: default
  to: [18 digit number]@g.us
  body:
    text: |
      Dryer is done, don't forget to take the clothes out.
enabled: true
action: whatsapp.send_message

Replace [18 digit number] with the number you captured earlier. This automation will now send the message to the entire group, and everyone will receive the notification from your personal assistant.

Summary

In this and the previous post, we’ve explored how to send notifications from Home Assistant to individual contacts and groups using WhatsApp. In the next part of this series, we’ll dive into sending images and audio messages to enhance your smart home experience.


Comments

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

Leave a Reply