POST Request - RESTFUL Sensor

Guys,

I live in a building and I figured out how to open the garage through a post request.

I would like to do this directly in HA.

In this case, the best solution is through a RESTFUL Sensor with a post?

Is the post only made when I request it?

Tks

RESTFUL switch?

Doh, I havent seen that option.

I guess that it will work.

Well, I dont have a OFF State but I guess its not a problem

Are you able to get any information on whether the garage is open or closed? If not, then I think you’d want a button in HA that can simply issue the POST request and it will toggle the garage.

First you’d set up a RESTful command which allows you to issue your POST request by calling a service.

Next you’d create a template button which would call the service you just created every time the button is activated.

Finally, you’d add something like a button card to a lovelace dashboard so you have an easy way to press the button.

1 Like

Hum… much better!

It’s working!

Next, I’ll try to find the request to get the status of the garage door.

Tks

Well, I tryed it on Developer Tools > Service and that worked.

But It didn’t quite understand how to crease the template button. Can you give me an example?

this is the rest command I made. I don’t need to pass any other information.

(Later I’ll put the authorization in the secret and maybe I’ll create a command to get a new authorization automatically)

image

If I create a template it will become an entity? sorry, but I’m a bit new to HA. I want to expose an entity to Alexa to open the garagem door. I know I can do that throw Script, right? Is there a way to create an entity?

Yes a template entity will create an entity. So if you put this code in your configuration.yaml file and then reload template entities (or restart HA if this is your very first template entity) then a new entity will show up called “Garage Door Button”.

If you already have template entities, make sure you don’t duplicate the template: heading.

template:
  - button:
      - name: Garage Door Button
        unique_id: garage_door_button
        press:
          service: rest_command.garagem
          data: {}

I don’t know if the data: {} line is required; you could try without it.

1 Like

Sorry, I see I didn’t answer all your questions. The button entity can be exposed to a Alexa and it will show up as a ’scene’ in the Alexa app. You should be able to say “Alexa turn on Garage Door Button” and the button will get activated.

You can also create a script instead of a button, and the script will show up in Alexa as a ‘scene’ also.

Another option is a template switch, which would show up in Alexa as switch. For the state of the switch, you can just have it turn back off automatically a few seconds after it is turned on.

1 Like

With or without data: {} worked.

Thanks

1 Like