WhatsApp Notifications From Home Assistant
by taste_the_code in Workshop > Home Improvement
2159 Views, 3 Favorites, 0 Comments
WhatsApp Notifications From Home Assistant
In my smart home setup with Home Assistant, I have several situations where I want to be notified about certain changes and conditions and since I already use WhatsApp, I wanted to set it up so I can get the notifications on it.
To send the notifications, I'm using a service called CallMeBot that is free but it can only send to a single number.
Supplies
By buying through the links below, you support the channel at no extra cost for you!
- Mini PC to run Home Assistant - https://s.click.aliexpress.com/e/_DDoIAMb
- Soldering iron - https://s.click.aliexpress.com/e/_mL7RitU
- Desoldering Wick - https://s.click.aliexpress.com/e/_okV5159
- Wire Snips - https://s.click.aliexpress.com/e/_mK8YCp4
- Helping hand - https://s.click.aliexpress.com/e/_EvcDULp
- Repair Set - https://s.click.aliexpress.com/e/_mMOtITY
- NodeMCU - https://s.click.aliexpress.com/e/_m0s6Uu6
- Jumper Wires - https://s.click.aliexpress.com/e/_DkWW1nZ
- Soldering Station - https://s.click.aliexpress.com/e/_DkA1M2L
- Prototyping PCBs - https://s.click.aliexpress.com/e/_Dcvrbu
Activate CallMeBot
To activate CallMeBot, you need to add its number as a contact in your phone and then send the following message to it: "I allow callmebot to send me messages"
This will cause it to send you an API key as well as a URL that you can use to trigger notifications to yourself.
Set Up Home Assistant Notification Service
With the service activated, you then need to add it to Home Assistant. Inside your configuration.yaml file, set the following notify service:
# Example configuration.yaml entry
notify:
- name: WhatsApp
platform: rest
resource: https://api.callmebot.com/whatsapp.php
data:
source: HA
phone: +34123123123 #enter your phone number here
apikey: 456789 #enter your apikey here (see Setup above)
To get that it is working, you can go to Developer Tools -> Services, and trigger it from there with a test message.
Set Up the Time Based Automation
The final step is to set up the automation that will trigger the notification. This automation can be based on anything you want and in my case I'm basing it on time.
The automation will run each day at 7:30 AM, check if the day is Monday and if it is, it will trigger the notification service to send out the notification message.
alias: Take out the trash notification
description: WhatsApp Message to take out the trash every Monday at 7:30 AM
trigger:
- platform: time
at: "07:30:00"
condition:
- condition: time
weekday:
- mon
action:
- service: notify.whatsapp
data:
message: It is time to take out the trash!
mode: single
Enjoy!
And with that, I will never forget to take out the trash ever again!
If you are into home automation or electronics projects I have a lot more that you can check out in my Instructables and on my YouTube channel.