Add custom header support for rest_command (#12646)

* Add support for specifying custom headers for rest_command.
* Added headers configuration to behave similarly to the rest sensor.
* Replaced test_rest_command_content_type which only validated the
  configuration with test_rest_command_headers which tests several
  combinations of parameters that affect the request headers.
This commit is contained in:
James Marsh 2018-02-28 06:16:31 +00:00 committed by Johann Kellerman
parent f5c633415d
commit f6c504610b
3 changed files with 82 additions and 15 deletions

View file

@ -35,7 +35,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_RESOURCE): cv.url,
vol.Optional(CONF_AUTHENTICATION):
vol.In([HTTP_BASIC_AUTHENTICATION, HTTP_DIGEST_AUTHENTICATION]),
vol.Optional(CONF_HEADERS): {cv.string: cv.string},
vol.Optional(CONF_HEADERS): vol.Schema({cv.string: cv.string}),
vol.Optional(CONF_JSON_ATTRS, default=[]): cv.ensure_list_csv,
vol.Optional(CONF_METHOD, default=DEFAULT_METHOD): vol.In(METHODS),
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,