HTTP request action in scenes (GET/POST/PUT/PATCH/DELETE)

Hello

Simply allow calling certain web pages with parameters from values sent by sensors

Hello, personally I don’t understand your need, could you elaborate a bit please?

No problem

For example, my robot vacuum has an API that allows me to control it
I would like to tell Gladys « clean the bedroom Â» and the request would be
http://192.168.X.XX/api/start_cleaning_zone?key=XXX&room=« bedroom Â»
The parameters can be sensor values or rooms or other

Another example for my « connected air conditioner Â» if the temperature goes above a certain threshold
http://192.168.X.XX/Clim/bedroom/on/« temperature -6 Â»

I think in these cases, we are getting closer to integrating new devices.

That said, sending HTTP requests could be useful for integrating custom webhooks, a bit like IFTTT.

One of the things I want to develop, and which looks like this, is an « HTTP Request Â» box in the scenes.

  • The user chooses the HTTP verb (GET/POST/PATCH/PUT/DELETE)
  • The API URL
  • The GET/POST/PATCH/PUT parameters depending on the request
  • The headers if authentication is needed

This will allow you to create webhooks to external services in the scenes, which can be useful :slight_smile:

Coming soon to the scenes :heart_eyes:

That’s great! :star_struck:

Will we be able to pass variables in the long term or will it just be a call to static URLs?

I would like to be able to pass variables to the end, yes :slight_smile:

And above all, retrieve the content of the response to use it in the scene afterwards.
For example, call a random API, and then send a message to the user with data from the API response :slight_smile:

Do you have an example in mind or could it be useful to call a dynamic URL?

In the meantime, I worked on adding headers to the requests, it wasn’t easy in terms of UI but I managed ^^

Hop, the feature has been merged into: Add an HTTP request action in scene to make GET,POST,PATCH,PUT,DELETE… · GladysAssistant/Gladys@e467c86 · GitHub

It will be released on the dev image tonight, in Gladys next week :slight_smile:

For the variable injection part into other scene fields, I would like to do something like Zapier does:

For example, this means that in a « send a message Â» action in the scenes, you could draw from data that has been retrieved by another action (retrieve a device value, HTTP request, etc…)

Problem: I tried to break down how they do it, and it looks tricky! they have a fake textarea that is 0 px and on top of it a kind of pre - code tag to display the text set at the same time as the « styled Â» variables (since it is not possible to have style in a classic textarea)

Does anyone know HTML/CSS and could do something like that with preact? :smiley:

Hello,

I’m not sure if I understood correctly, but you want to be able to insert values based on the return of previous actions (HTTP request, etc…)?
For devices, you already have the list of devices and their values somewhere, right?
For HTTP requests, if they are customizable, it gets complicated and you need to ask the user for the returned data and how (the back will parse the return, but where are the data in this return?, some APIs will return a data object directly, others will have additional information (lists for example with pagination and thus the real data are one level below), etc…) in order to be able to parse the return.

For the front end, you need to look at components of type combobox/autocomplete to see exactly how they do it, I think that most of the time it’s a hidden select to save the data and a text field/div to display it, the selection list is a simple list. (after with preact you may no longer need the select, you should be able to save the selection in the state, (never done preact, I prefer vue ^^ but the principle should remain the same))

Otherwise, from a user’s point of view, having a textarea body, for regular users, it doesn’t mean anything, you need like in your example headers, you add parameter lines (a parameter name field, a value field, see Postman for example (the form-data part), with an option for the format to be sent (json, form-data, etc…), the advantage of this solution is that whether it’s a GET method or other you pass the parameters in the same way it’s the back that renders the right format (query string or body, depending on the method, and the json or other format depending on the option chosen).

I don’t know if I brought you any ideas or solutions but well ^^

Good evening to everyone

Hello @wazalop, I was just talking about frontend development, how to visually do in HTML/CSS the screenshot I posted above :smiley: I have the data!

Edit: Dev image of Gladys with the feature in progress (https://github.com/GladysAssistant/Gladys/actions/runs/401136485)