@Spaceman_Spiff I’ve run into another roadblock with my attempt to use actions from HABApp. I am trying to figure out the correct payload or body for an Action call via the REST API Explorer. I can’t find any examples in the forums, maybe because it’s a seldom used feature. What I’m trying to do is access the Astro binding actions. In jython this is how I would do it:
sunActions = actions.get("astro","astro:sun:local")
currentElev = sunActions.getElevation(zdt_now()).floatValue()
This works fine and returns the current Elevation of the Sun. However I can’t figure out the appropriate way to call this in the API explorer. What I have tried is:
In the API explorer I first do GET /actions/{thingUID} where thingUID = astro:sun:local
This returns a big JSON block with all of the available actions. The one I want is:
{
"actionUid": "astro.getElevation",
"label": "get the elevation",
"description": "Get the elevation for a given time.",
"inputs": [
{
"name": "date",
"type": "java.time.ZonedDateTime",
"label": "Date",
"description": "Considered date",
"required": false,
"tags": [],
"reference": "",
"defaultValue": ""
}
],
"outputs": []
}
Then I try a POST /actions/{thingUID}/{actionUID} where thingUID = astro:sun:local
and actionUID = astro.getElevation
. In the body I’ve tried everything I can think of, but I can’t figure out how to properly pass it the java.time.ZonedDateTime that it is apparently looking for. I have tried:
{
"additionalProp1": "2019-09-03T15:22:33.650-05:00",
"additionalProp2": {},
"additionalProp3": {}
}
This Returns 200 OK and {}
in the response body
{
"actionUid": "astro.getElevation",
"label": "get the elevation",
"description": "Get the elevation for a given time.",
"inputs": [
{
"name": "date",
"type": "java.time.ZonedDateTime",
"label": "Date",
"description": "Considered date",
"required": false,
"tags": [],
"reference": "",
"defaultValue": "2019-09-03T15:22:33.650-05:00"
}
],
"outputs": []
}
This Returns 200 OK and {}
in the response body
{
"date": "2019-09-03T15:22:33.650-05:00"
}
This Returns 200 OK and {}
in the response body
Basically I’m just guessing and I don’t know how to input a time properly so that it returns the Elevation of the Sun at that given time. Any help is greatly appreciated!