Skip to content

FaserF/ha-whatsapp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

398 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ’ฌ HA WhatsApp Integration

WhatsApp Logo

HACS Custom GitHub Release

Connect your Home Assistant instance directly to WhatsApp using the "Linked Devices" (Web) protocol. No Business API required. ๐Ÿš€

Requires the Home Assistant App to function. This integration communicates with the App to send and receive messages.


Component Version Status
App (Stable) App Version engine
App (Edge) App Edge engine-dev
Integration (Stable) Integration Stable interface
Integration (Beta) Integration Beta testing
Activity Last Commit

โค๏ธ Support This Project

I maintain this integration in my free time alongside my regular job โ€” bug hunting, new features, testing on real devices. Test hardware costs money, and every donation helps me stay independent and dedicate more time to open-source work.

This project is and will always remain 100% free. There are no "Premium Upgrades", paid features, or subscriptions. Every feature is available to everyone.

Donations are completely voluntary โ€” but the more support I receive, the less I depend on other income sources and the more time I can realistically invest into these projects. ๐Ÿ’ช

GitHub Sponsorsย ย  PayPal


Caution

Legal Disclaimer / Haftungsausschluss

Using this integration may violate WhatsApp's Terms of Service. WhatsApp explicitly prohibits unauthorized automated or bulk messaging.

The developers of this project assume no liability for any banned or blocked accounts. Use at your own risk. For more information, please read the official Terms of Service.


๐Ÿ“ฅ Installation

HACS (Recommended)

Open your Home Assistant instance and open a repository inside the Home Assistant Community Store.

  1. Click the button above or add this repository as a custom repository in HACS:
    • Go to HACS โ†’ Integrations โ†’ โ‹ฎ (menu) โ†’ Custom repositories
    • Add: https://github.com/FaserF/ha-whatsapp (Category: Integration)
  2. Install "Home Assistant WhatsApp" from HACS.
  3. Restart Home Assistant.
  4. Add the integration via Settings โ†’ Devices & Services โ†’ Add Integration โ†’ WhatsApp.

Manual Installation

  1. Download the latest release from GitHub Releases.
  2. Extract and copy the whatsapp folder to config/custom_components/.
  3. Restart Home Assistant.

๐ŸŒŸ Features

  • ๐Ÿ“ฒ Local & Private: Acts as a "Linked Device" (like WhatsApp Web). No cloud bridge, no external servers.
  • ๐Ÿ’ฌ Rich Messaging: Send Text, Images, Videos, Audio (PTT), Documents, and Locations.
  • ๐Ÿ“Š Interactive Content: Send Polls, Buttons, and List Menus to interact with users.
  • ๐Ÿ”„ Two-Way Communication: React to incoming messages, button clicks, and poll votes.
  • ๐Ÿ›ก๏ธ Modern Standards: Fully compatible with the Home Assistant notify standard (ADR-0010).
  • ๐Ÿ“ Message Management: Edit or Revoke (delete) messages after sending.
  • ๐Ÿ•ต๏ธ Discovery Tools: Built-in service to find Group IDs without checking logs.
  • ๐Ÿค– Automation Triggers: Real-time events for everything happening on WhatsApp.
  • ๐Ÿ›ก๏ธ Native Control: Built-in commands (ha-app-*) to check status, restart, or run diagnostics directly via WhatsApp.
  • ๐Ÿ”” Admin Alerts: Proactive system notifications for WhatsApp loss/restore and HA Core/Integration updates.
  • ๐ŸŒ Localization: Full native support for English and German (DE/EN).

๐Ÿ“š Documentation

The most up-to-date and detailed documentation is available at our Official Documentation Site.

Guide Description
๐Ÿš€ Full Guide Installation, Services, Automations, and Pro-Tips.
๐Ÿ“š Whitelist Guide Restrict interaction to specific users/groups.
๐Ÿ”˜ Buttons Guide Deep dive into interactive buttons and limitations.
๐Ÿ“– Local Examples Quick reference for YAML snippets inside this repository.
๐Ÿ› ๏ธ Troubleshooting Diagnostic tools and fixing common connection issues.

๐Ÿ’ก How to use

The WhatsApp Sensor

The integration provides a binary sensor (e.g., binary_sensor.whatsapp).

  • State: Indicates if the integration is successfully connected to the App.
  • Attributes:
    • messages_sent: Total number of messages sent since restart.
    • last_message_content: Content of the last sent message.
    • last_message_target: Phone number of the last recipient.

If the sensor is disabled, check your Home Assistant "Entities" settings and enable it. It tracks the connection health to the WhatsApp Home Assistant App.

Services

1. Native WhatsApp Services (Recommended)

Use these for the most robust experience in YAML.

service: whatsapp.send_message data: target: '+491234567890' message: 'Hello from HA!'

2. Legacy Notify (notify.whatsapp)

Great for sending to multiple numbers at once or for simple alerts.

service: notify.whatsapp data: message: 'Washing machine is done! ๐Ÿงบ' target: - '+491234567890' - '123456789@g.us'

3. Modern Notify Action (notify.send_message)

Warning

Only use this in the Visual Editor (UI). In YAML, it often fails with extra keys not allowed.

action: notify.send_message target: entity_id: notify.whatsapp data: message: 'Hello World!'

4. Interactive Polls ๐Ÿ“Š

Gather feedback or make decisions with family/groups.

service: whatsapp.send_poll data: target: '+491234567890' question: 'What should we have for dinner? ๐Ÿ•' options: - 'Pizza' - 'Sushi' - 'Cooking myself'

5. Disappearing Messages โณ

Ensure privacy by setting an expiration time (matching chat settings).

service: whatsapp.send_message data: target: '+491234567890' message: 'This message will disappear according to chat rules.' expiration: 86400 # 24 hours

Service Examples

We've provided examples for Personal (Direct) chats and Group chats.

  • Direct ID: +491234567890 (Phone number with country code)
  • Group ID: 123456789-123456@g.us (Find this via Events, see below)

1. Send Text Message ๐Ÿ“

Click to show YAML examples

Direct Chat:

service: whatsapp.send_message data: target: '+491234567890' message: 'Hello!'

Group Chat:

service: whatsapp.send_message data: target: '123456789-123456@g.us' message: 'Hello Everyone! ๐Ÿ‘‹'

2. Send Polls ๐Ÿ“Š

Click to show YAML examples

Direct Chat:

service: whatsapp.send_poll data: target: '+491234567890' question: 'Lunch?' options: ['Pizza', 'Sushi']

Group Chat:

service: whatsapp.send_poll data: target: '123456789-123456@g.us' question: 'Team Building Activity?' options: - 'Bowling ๐ŸŽณ' - 'Cinema ๐Ÿฟ' - 'Hiking ๐Ÿฅพ'

3. Send Image ๐Ÿ–ผ๏ธ

Click to show YAML examples

Direct Chat:

service: whatsapp.send_image data: target: '+491234567890' url: 'https://www.home-assistant.io/images/favicon.jpg' caption: 'Check this out!'

Group Chat:

service: whatsapp.send_image data: target: '123456789-123456@g.us' url: 'https://www.home-assistant.io/images/favicon.jpg' caption: 'New Logo Proposal'

4. Send Location ๐Ÿ“

Click to show YAML examples

Direct Chat:

service: whatsapp.send_location data: target: '+491234567890' latitude: 52.5200 longitude: 13.4050 name: 'Meeting Point'

Group Chat:

service: whatsapp.send_location data: target: '123456789-123456@g.us' latitude: 48.8566 longitude: 2.3522 name: 'Holiday Home' address: 'Paris, France'

5. Send Buttons ๐Ÿ”˜

Note: Button support varies by WhatsApp version.

Click to show YAML examples

Direct Chat:

service: whatsapp.send_buttons data: target: '+491234567890' message: 'Arm Alarm System?' footer: 'Security Automation' buttons: - id: 'arm_home' displayText: 'Arm Home ๐Ÿ ' - id: 'arm_away' displayText: 'Arm Away ๐Ÿ›ก๏ธ'

Group Chat:

service: whatsapp.send_buttons data: target: '123456789-123456@g.us' message: 'Who is coming?' buttons: - id: 'yes' displayText: "I'm in!" - id: 'no' displayText: "Can't make it"

6. Reactions & Presence

Click to show YAML examples

React to a message (Direct or Group):

service: whatsapp.send_reaction data: target: '123456789-123456@g.us' message_id: 'BAE5F...' # ID from event reaction: 'โค๏ธ'

Set Presence (Direct or Group):

service: whatsapp.update_presence data: target: '+491234567890' presence: 'composing' # status: typing...

๐Ÿค– Automating Replies

You can use Home Assistant automations to react to incoming messages, button clicks, and poll votes.

1. React to a Button Click

When a user clicks a button, a whatsapp_message_received event is fired with type: button_reply (depending on App version). The most important field is buttonId or selectedId.

alias: Handle Alarm Button trigger: - platform: event event_type: whatsapp_message_received event_data: type: 'button_reply' # Check your event listener for exact type buttonId: 'arm_away' # Matches the ID you sent action: - service: alarm_control_panel.alarm_arm_away target: entity_id: alarm_control_panel.home_alarm - service: whatsapp.send_message data: target: '{{ trigger.event.data.from }}' message: 'Alarm Armed! ๐Ÿ›ก๏ธ'

2. React to a Poll Vote

Polls fire updates when votes change.

alias: Pizza Poll Handler trigger: - platform: event event_type: whatsapp_message_received event_data: type: 'poll_update' condition: - condition: template value_template: "{{ 'Pizza' in trigger.event.data.vote }}" action: - service: whatsapp.send_message data: target: '{{ trigger.event.data.from }}' message: 'Great choice! ๐Ÿ•' 

3. General Message Handler

alias: WhatsApp Auto-Reply trigger: - platform: event event_type: whatsapp_message_received event_data: content: 'Status' condition: [] action: - service: whatsapp.send_message data: target: '{{ trigger.event.data.from }}' message: "System is Online! ๐ŸŸข\nBattery: {{ states('sensor.phone_battery_level') }}%"


๐Ÿ—๏ธ Native Control & Notifications

This integration works in tandem with the WhatsApp App, which provides several built-in features that don't require any YAML configuration:

๐ŸŽฎ Control Commands

If you are configured as an Admin, you can control the addon directly via WhatsApp by sending:

  • ha-app-status: Full health check (Versions, Uptime, Memory).
  • ha-app-help: List all available control commands.
  • ha-app-logs: View the latest connection events.
  • ha-app-diagnose: Run a full diagnostic of all message types.
  • ha-app-restart: Trigger a reconnect of the WhatsApp session.

๐Ÿ”” System Status Notifications

The app can automatically notify administrators about critical events:

  • โœ… Update Success: Reports when HA Core, the Addon, or this Integration has been successfully updated.
  • ๐Ÿ”„ HA Restart: Notifies you when HA Core is back online after a restart/reboot.
  • ๐ŸŒ Connectivity: Alerts if the connection to WhatsApp or HA Core is lost/restored, including downtime duration.

๐Ÿ‘‹ Welcome Message

The bot automatically sends a role-aware greeting to new users on their first direct contact, ensuring they know how to interact with the system.


๐Ÿ†” Finding Chat IDs & Group IDs

To send messages, you need a target ID. The integration makes finding these very easy.

1. Private Chats (Phone Numbers)

Use the phone number in international format. The integration automatically adds the required suffix.

  • Example: +491234567890 or 491234567890

2. Group IDs (The Easy Way) ๐Ÿ†

Group IDs look like 120363012345678901@g.us. Instead of searching through logs or listening to events, use the built-in Search Service:

  1. Go to Developer Tools โ†’ Services.
  2. Select whatsapp.search_groups.
  3. (Optional) Enter a name_filter.
  4. Click Call Service.
  5. Check your Notifications (Bell icon ๐Ÿ”” in the sidebar)! A table with all your groups and their IDs will appear instantly.

3. Listening to Events (Advanced)

If you need the ID of a specific incoming message or a dynamic sender:

  1. Go to Developer Tools โ†’ Events.
  2. Listen to whatsapp_message_received.
  3. Send a message to the bot. The ID is in the from field.

๐Ÿ› ๏ธ Requirements & App

Important

This integration DOES NOT work alone. It is strictly a bridge to the HA WhatsApp Home Assistant App.

Why?

WhatsApp Web protocols are complex and require a headless browser to maintain encryption and session state.

  • The App: Runs the browser (Puppeteer/Playwright), handles QR scanning, and encryption.
  • The Integration: Connects to the App API to expose services and sensors to Home Assistant.

You Must install the App from the repo above for this to work.


๐Ÿท๏ธ Versioning & Releases

We use a structured release cycle to ensure stability while providing new features:

  • Stable (v1.x.x): Recommended for all users. Tested and verified for production use.
  • Beta (v1.x.xbX): Public testing of new features. Recommended if you want the latest tech and can provide feedback. Available via HACS "Redownload" -> "Show beta versions".
  • Edge/Dev (v1.x.x-dev): Bleeding edge from the master branch. May be unstable. Only for developers.

Releases are automatically created when the version in manifest.json is updated.


๐Ÿ“œ License

MIT License. Open Source & Free. โค๏ธ