How to have http endpoints on espeasy for API calls?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
JR01
Normal user
Posts: 260
Joined: 14 Feb 2016, 21:04
Location: South Africa

How to have http endpoints on espeasy for API calls?

#1 Post by JR01 » 03 Aug 2020, 20:30

Hi, I have never used any of the http methods to control or send status using esp yet.

On HomeBridge, they have a web-sprinkler node which reads a /status endpoint, and then expect this api endpoint https://www.npmjs.com/package/homebridg ... nterfacing to send back the following information (from the espeasy endpoint /status - to the requestor) - about the status of the sprinkler valves, which will be gpios:

Code: Select all

[
  {
    "zone": 1,
    "state": 0
  },
  {
    "zone": 2,
    "state": 0
  },
  {
    "zone": 3,
    "state": 0
  },
  ...
]
Is this possible with ESP? With generic HTTP Controller, or what?
-----------
IOTPLAY. Tinkerer, my projects are @ http://GitHub.com/IoTPlay, and blog https://iotplay.org. Using RPi, Node-Red, ESP8266 to prove Industry 4.0 concepts.

JR01
Normal user
Posts: 260
Joined: 14 Feb 2016, 21:04
Location: South Africa

Re: How to have http endpoints on espeasy for API calls?

#2 Post by JR01 » 03 Aug 2020, 20:52

I found this post https://www.letscontrolit.com/forum/vie ... 8&start=10 which shows how to use http generic, and Tools > Advanced > Templates - is that the way? Is their perhaps a better way?

It looks like the above way you 'send' data, where-as the api call will call the endpoint, and only then expect to get the info....

And, it seams this info per Tools > Advanced > Template have been taken into the generic http controller, I think. But I am very lost here....
-----------
IOTPLAY. Tinkerer, my projects are @ http://GitHub.com/IoTPlay, and blog https://iotplay.org. Using RPi, Node-Red, ESP8266 to prove Industry 4.0 concepts.

TD-er
Core team member
Posts: 8736
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: How to have http endpoints on espeasy for API calls?

#3 Post by TD-er » 03 Aug 2020, 22:30

It is not really clear to me what you want to do in ESPEasy...
Do you want to send out something to some other device running HomeBridge?
Or do you want to send something from HomeBridge to ESPEasy to control something on ESPEasy?

JR01
Normal user
Posts: 260
Joined: 14 Feb 2016, 21:04
Location: South Africa

Re: How to have http endpoints on espeasy for API calls?

#4 Post by JR01 » 04 Aug 2020, 16:20

HomeBridge - the link I showed above - expects a json endpoint, like http://espeasy1.home/status - which as HomeBridge connects to it, serves back the status of the pins - exactly in that format as shown in post.

There are other examples in that link of endpoints it expects - to read - and instruct....
-----------
IOTPLAY. Tinkerer, my projects are @ http://GitHub.com/IoTPlay, and blog https://iotplay.org. Using RPi, Node-Red, ESP8266 to prove Industry 4.0 concepts.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 36 guests