Webhook + Gladys plus

Hello,

I’m looking to improve the netatmo service (which is in PR).

Netatmo has a webhook service that allows you to retrieve events such as the last person seen by a camera, or the last movement detected by a camera, and the goal is to retrieve an image from the camera. This would greatly improve the service.

To do this, you need to open gladys to the outside. Hence the interest of Gladys Plus!

Question for you then @pierre-gilles, is it easy to contribute to Gladys Plus, have you planned for this kind of case?

Thanks :slight_smile:

We can have a call if you want to discuss it :slight_smile:

I am 100% for adding this kind of thing in any case!

When are you available?

Are you working on Gladys today? Available around 11:30 am if you’d like :slight_smile:

Yes I’m working on Gladys today!

Perfect for 11:30, I’ll send you a link. See you later :slight_smile:

@damalgos It’s good, I’ve put a webhook online for you, accessible at:

POST https://api.gladysgateway.com/v1/api/netatmo/:OPEN_API_KEY

On the Gladys side, in your branch, you go to the file:

server/lib/gateway/handleNewMessage.js

And you add at the end:

 if (data.type === 'gladys-open-api' && data.action ===  'netatmo-webhook') {
    this.event.emit(EVENTS.GATEWAY.NEW_MESSAGE_NETATMO, data.data);
    cb({ status: 200 });
  }

The data will look like this:

 const data = {
      user_id: 'XXXXXXXXX' // The uuid of the user making the request. Probably unnecessary in your case.
      netatmo_data: {} // The body of the netatmo webhook
};

Don’t forget to create the « EVENTS.GATEWAY.NEW_MESSAGE_NETATMO » in the constants, and voila, you should receive an event when a webhook is received

I couldn’t test it much in real conditions, so it’s possible we’ll discover things: is the netatmo payload too heavy or not serializable?

Keep me posted if it doesn’t work!

:astonished:

Great! Thanks, it’s perfect I’ll try it out :smiley:

I’ll let you know if there’s an issue but it should be fine.

Have you seen the simplicity and speed of integration? :smiley: A real gem this gateway :gem_stone:

Hello! Quick question, will webhooks also be usable without Gladys Plus?

Hi,

Well, I can’t really comment too much on this topic, but it’s true that it’s an option to consider for people who have a Gladys instance exposed on the internet. After all, it’s not for everyone (security, etc. :)).

So, as a developer, I assume we’re using gladys more. But if someone develops a feature like webhooks on local gladys, why not, I’ll use it :slight_smile: