Sending notifications to a whatsapp group

We implemented sending messages to whatsapp groups precisely to avoid sending the same message to all the members of one family, instead we just need to send one to the whatsapp group; but you’re right, the use-case of sending alerts when the washing machine finishes was definitively out of our scope when we did the free tier sizing. We wouldn’t be able to afford over three users with kids at home :laughing:

@lu4t Hi, thank you for your development on this.

I have read your tutorial regarding payload on this payload-schemas. I was wondering if it possible to display any sensor value like temperature sensor in the payload. As example below:

rest_command:
  send_whatsapp_boiler_temperature:
    url: "https://whin2.p.rapidapi.com/send2group?gid=1231654654123154548787"
    method: POST
    headers:
      content-type: application/json
      X-RapidAPI-Host: whin2.p.rapidapi.com
      X-RapidAPI-Key: 123456
    payload: '{ "image": { "url": "https://i.ibb.co/image.png" }, "caption": "Boiler too cold !!! Current temperature is - {sensor.boiler_temperature}"}'

I know above code wont work, i just want to show an example of what i try to achieve.

It can be achieved, but you need to parse the template with the payload before you execute the rest command.
In particular, you need this: {sensor.boiler_temperature} to be transformed to the value of the sensor before the payload is formed. For that, you need to create a template…

Let’s say this is the template that takes the value:

sensor:
  - platform: template
    sensors:
      boiler_temperature_template:
        friendly_name: "Boiler Temperature Template"
        value_template: "{{ states('sensor.boiler_temperature') }}"

Then you need to adjust the payload to make use of the template:

rest_command:
  post_api_command:
    url: "YOUR_URL_HERE"
    method: post
    headers:
      content-type: application/json
      X-RapidAPI-Host: whin2.p.rapidapi.com
      X-RapidAPI-Key: 123456
    payload: >
      {
        "image": { "url": "https://i.ibb.co/image.png" },
        "caption": "Boiler too cold !!! Current temperature is - {{ states('sensor.boiler_temperature_template') }}"
      }

Using this schema should do the job.

1 Like

Thank you so much! as your subscriber, i appreciate your fast reply.

Below is my working code, based on the @lu4t guidance as above.

rest_command:
  send_whatsapp_boiler_temperature_high:
    url: "https://whin2.p.rapidapi.com/send2group?gid=1234567890123456789"
    method: post
    headers:
      content-type: application/json
      X-RapidAPI-Host: whin2.p.rapidapi.com
      X-RapidAPI-Key: 12345
    payload: >
      {
        "image": { "url": "https://i.ibb.co/Temp-High.jpg" },
        "caption": "SUHU TINGGI - *{{ states('sensor.boiler_temperature') }}°C*"
      }

  send_whatsapp_boiler_temperature_low:
    url: "https://whin2.p.rapidapi.com/send2group?gid=1234567890123456789"
    method: post
    headers:
      content-type: application/json
      X-RapidAPI-Host: whin2.p.rapidapi.com
      X-RapidAPI-Key: 12345
    payload: >
      {
        "image": { "url": "https://i.ibb.co/Temp-Low.jpg" },
        "caption": "SUHU RENDAH - *{{ states('sensor.boiler_temperature') }}°C*"
      }

And the output:

1 Like

Super THANK YOU!
Works for me.