Skip to main content

JOD Worker Executor Http

When an action must be executed, this executor performs a HTTP Request defined via HTTP Request configs.

Before execute the request, the requestUrl and the requestBody strings are updated and all their placeholder are replaced with current Pillar, State and Action properties.
After that execute the HTTP Request with updated url and body.


Firmware Configs - Executor

requestBody

String format used to generate the HTTP Request body. Default value ''.

This string can contains Pillar's, State's and Action's Placeholder that will be replaced before executing the HTTP Request.

This property is updated with Pillar's Placeholder on worker initialization and with State Placeholder and Action Placeholder on executing action.


Firmware Configs - Http request

HTTP Requests are performed using the DefaultHTTPClient from the JOSP Commons library.

Following Firmware Configs allow you customize the request that must be perform on worker execution.
Those configs are defined and used by HTTPInternal class.

requestUrl

The url used for the HTTP Request. It's mandatory.

This string is used to format the final url for the HTTP Request.
The requestUrl string is updated during worker initialization and then each time the executor execute an action.

This property is updated with Pillar's Placeholder on worker initialization and with State Placeholder on pulling state.

requestVerb

The HTTP method to use for the HTTP Request. Default 'GET'.

This string can be one of the following values:

  • 'GET'
  • 'POST'
  • 'PUT'
  • 'DELETE'
  • 'HEAD'
  • 'OPTIONS'
  • 'TRACE'
  • 'PATCH'

Those values are coming from the Scribe Java library.

This property is updated with Pillar's Placeholder on worker initialization.

requestTimeOut

The HTTP Request's timeout in seconds. Default '30'.

This property is updated with Pillar's Placeholder on worker initialization.

requestIgnoreSSLHosts

Set this string to 'True' to ignore "SSL: Invalid Hostname" error. Default 'false'.

If the HTTP Server that receive the HTTP Request is set to use the SSL encryption but his certificate or hostname are not valid.

This property is updated with Pillar's Placeholder on worker initialization.

availabilityRetrySeconds

When the HTTP Server is not reachable, this property define how much seconds wait before retry contacting the server. Default '10'.

This property is not used in the Executor HTTP worker execution.

This property is updated with Pillar's Placeholder on worker initialization.


Examples

struct.jod: BoolenAction/Http @ JOD Philips Hue
"Switch": {
"type": "BooleanAction",
"puller": "http://requestUrl='https://philips-hue-tres.local/api/Xex9YLRxERFf0TliilWFj3LkmjtCd2iGLmQSktYY/lights/1';requestIgnoreSSLHosts=true;",
"executor": "http://requestUrl='http://philips-hue-tres.local/api/Xex9YLRxERFf0TliilWFj3LkmjtCd2iGLmQSktYY/lights/1/state';requestVerb=PUT;requestIgnoreSSLHosts=true;requestBody='{\"on\":%VAL%}'"
}
struct.jod: RangeAction/Http @ JOD Philips Hue
"Brightness": {
"type": "RangeAction",
"puller": "http://requestUrl='https://philips-hue-tres.local/api/Xex9YLRxERFf0TliilWFj3LkmjtCd2iGLmQSktYY/lights/1';requestIgnoreSSLHosts=true;",
"executor": "http://requestUrl='http://philips-hue-tres.local/api/Xex9YLRxERFf0TliilWFj3LkmjtCd2iGLmQSktYY/lights/1/state';requestVerb=PUT;requestIgnoreSSLHosts=true;requestBody='{\"bri\":%VAL_INT%}'",
"min": "0",
"max": "254",
"step": "25"
}