Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


  • 0

Whatsapp integration with fibaro


Question

Posted

How can I integrate whats app with Fibaro HC2.

Please login or register to see this link.

.

 

I know that this post already exists. The answer given in this post on this forum is an absolute telegram question.

 

And I want to know, Can WhatsApp be integrated now?

Recommended Posts

  • 0
Posted
2 hours ago, jgab said:

Try

Please login or register to see this code.

...or move your code to a  QA...

Thanks!  Working.

  • 0
Posted
On 2/6/2022 at 1:08 PM, ethanmiles said:

How can I integrate whats app with Fibaro HC2.

Please login or register to see this link.

.

 

I know that this post already exists. The answer given in this post on this forum is an absolute telegram question.

 

And I want to know, Can WhatsApp be integrated now?

 Hi

 

 First step: follow the steps (1-3) from the link > 

Please login or register to see this link.

 

and after you get the activation number make a new fibaro Lua scene like >

 

local function encode(url)
  if url == nil then
    return
  end
  url = url:gsub("\n", "\r\n")
  url = url:gsub("([^%w _%%%-%.~])", function(c) return string.format("%%%02X", string.byte(c))  end)
  url = url:gsub(" ", "+")
  return url
end

local function sendMessage(number,apikey,message)
  local url = string.format("https://api.callmebot.com/whatsapp.php?phone=%s&text=%s&apikey=%s",
    number,encode(message),apikey)
    net.HTTPClient():request(url,{  options = { checkCertificate  = false }})
end

sendMessage("activated mobile number",apikey,"Test text");  

 

 

Working with iphone WhatsApp, but I didn't get on Android. I don't know why and the received link working.

 

  • 0
Posted
On 2/13/2022 at 2:12 PM, jgab said:

Try

Please login or register to see this code.

...or move your code to a  QA...

 

Hi 

I have made this changes and working, I get the messages on iPhone's whatsapp, and I activated on a second number with android whatsapp, and the received link working on this one but the messages sent trough this script doesn't arrive on Android's whatsapp (different activated mobile number).I get messages only on iPhone.

Do you know why ?

  • 0
Posted (edited)

@jgab @iTibor

Hi guys.

I'm new in Fibaro world (I had a Vera Secure controller before) and I have a HC3 that I would like to connect to Whatsapp.

 

So generate an API key and I create a QA with this code you share here in the Action panel:

Please login or register to see this code.

and it works correctly.

 

I need to send a whatsapp message when, for example, a sensor door is open.

I created a LUA scene with the condition that the window sensor is open. Then I wrote this in Action panel (with my numbers, of course)

Please login or register to see this code.

And activate the scene but it doesn't seem to work.

 

What am I doing wrong?

 

Thanks!

Edited by COAT
  • 0
Posted
12 hours ago, COAT said:

@jgab @iTibor

Hi guys.

I'm new in Fibaro world (I had a Vera Secure controller before) and I have a HC3 that I would like to connect to Whatsapp.

 

So generate an API key and I create a QA with this code you share here in the Action panel:

Please login or register to see this code.

and it works correctly.

 

I need to send a whatsapp message when, for example, a sensor door is open.

I created a LUA scene with the condition that the window sensor is open. Then I wrote this in Action panel (with my numbers, of course)

Please login or register to see this code.

And activate the scene but it doesn't seem to work.

 

What am I doing wrong?

 

Thanks!

Are you sure the scene triggers? Print a log.

Do you see anything in the log of QA 318?

Add a log.

Please login or register to see this code.

 

  • 0
Posted
On 3/25/2022 at 7:18 AM, jgab said:

Are you sure the scene triggers? Print a log.

Do you see anything in the log of QA 318?

Add a log.

Hi, thank you for your answer.

I am sure about the scene trigger because I setted that a message should be sent and a light should turn on when the door is opened and the latter works fine.

 

But adding a log for sendMessage function and for the url I found that received parameters were wrong.

 

I'll explain.

In the scene I wrote

Please login or register to see this code.

In the log i read this

Please login or register to see this code.

As you can see, the "plus" symbol was read as a "space" before the number but, in my string, I hadn't blank space in url function

Please login or register to see this code.

So, I deleted "+" from the scene function and added it in url

Please login or register to see this code.

I try again and in log file I read

Please login or register to see this code.

(I think that the "%21" is the encode of "!" character)

 

I don't know why but it works.

 

Is it possible the string in LUA (from the scene) are coded differently in QA function?

  • 0
Posted

Yes, you ran into the "bug" that parameters are transformed in fibaro.calls. 

I did a test of your code but between 2 QAs and there the '+' survives so I didn't bring it up. From a Scene it's a different matter...

Here is a post I did some time ago with more "interesting" transformations of arguments.

 

  • 0
Posted
Hi
 
I have migrated from HC2 to HC3 (5.120.10)
And my whastapp notification stopped to send message 
Can you help me?
 
The Lua scene looks like this>
 
DECLARATIONS panel:
{}
 
ACTIONS:
 
local function encode(url)
  if url == nil then
    return
  end
  url = url:gsub("\n""\r\n")
  url = url:gsub("([^%w _%%%-%.~])"function(c) return string.format("%%%02X", string.byte(c))  end)
  url = url:gsub(" ""+")
  return url
end
local function sendMessage(number,apikey,message)
  local url = string.format("https://api.callmebot.com/whatsapp.php?phone=%s&text=%s&apikey=%s",
    number,encode(message),apikey)
    net.HTTPClient():request(url,{  options = { checkCertificate  = false }})
end
sendMessage(MYNUMBER,APIKEY,"message");
  • 0
Posted

Hi @iTibor, my functions are a little bit different from yours.

On 10/29/2022 at 2:21 PM, iTibor said:
local url = string.format("https://api.callmebot.com/whatsapp.php?phone=%s&text=%s&apikey=%s",

in the url, I added a "+" before the "%s" in "phone".

So, my string is:

Please login or register to see this code.

Otherwise the function didn't work.

 

Furthermore,

On 10/29/2022 at 2:21 PM, iTibor said:
net.HTTPClient():request(url,{  options = { checkCertificate  = false }})

I have not " options = { checkCertificate  = false }". So, my string is:

Please login or register to see this code.

but I don't know the differences.

 

At the end:

On 10/29/2022 at 2:21 PM, iTibor said:
sendMessage(MYNUMBER,APIKEY,"message");

MYNUMBER, in my case, is a string. So,

Please login or register to see this code.

 

I hope this help you

  • 0
Posted (edited)

Hi @COAT

 

Thank you and I have made changes like you suggested: ( so my LUA script look like this - in ACTIONS panel

 

local function encode(url)
  if url == nil then
    return
  end
  url = url:gsub("\n""\r\n")
  url = url:gsub("([^%w _%%%-%.~])"function(c) return string.format("%%%02X", string.byte(c))  end)
  url = url:gsub(" ""+")
  return url
end
local function sendMessage(number,apikey,message)
  local url = string.format("https://api.callmebot.com/whatsapp.php?phone=+%s&text=%s&apikey=%s",number,encode(message),apikey)
   net.HTTPClient():request(url,{})
end
sendMessage("+11111111111",123456,"new code message test ");
 
of course I put my number and my apikey
 
but still I didn't get anything
 
Edited by iTibor
  • 0
Posted

Hi @iTibor

You have to remove the "+" in sendMessage so your last row will be

Please login or register to see this code.

Otherwise your phone number will have two "+" (one for local.url and one for sendMessage) and you'll send the request to "++11111111111" ?

  • 0
Posted

Hi @COAT

 

I have tried like this to:

sendMessage("41111111111",123456,"new code message test 2 ");
but still I don't get the message on whatsapp
  • 0
Posted

Ah wait @iTibor!

I think that there is a mistake in your code that I haven't noted before.

 

I assume that you added a Quickapp device.

 

You wrote

Please login or register to see this code.

but the correct syntax is

Please login or register to see this code.

without "local" before function and with "QuickApp:" before function name.

 

Therefore, you have to add a QuickApp function where to invoke "sendMessage" function itself.

So your code will be:

Please login or register to see this code.

Then you have to add the function name in "onReleased" section of your button like this

Please login or register to see this image.

/monthly_2022_11/image.png.0e77d8ef94ace5bd24b259e1def146e7.png" />

 

I tried to create a scene where, when something happens, the button of my QuickApp is pressed and a whatsapp message is sent to me

It works for me, this way.

  • Like 1
  • 0
Posted (edited)

I'm new in Quickapp stuff

 

I have made a new Quickapp  like this>    -still not working

Please login or register to see this attachment.

Edited by iTibor
  • 0
Posted

Hi @COAT

 

Working!

 

 Thank you very much.... now I have to find how is working this Quickapp stuff

  • 0
Posted
13 hours ago, iTibor said:

Hi @COAT

 

Working!

 

 Thank you very much.... now I have to find how is working this Quickapp stuff

Glad to hear it ^_^

  • 0
Posted

how can we/I call this function from any other Scene?

  • 0
Posted

Hi @emielstroeve

 

In the block scene you have to select the trigger option(s) and on the execution part you have to select this the Whatsapp sending Quickapp and /press button and choos the button, and working

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...