Hi all,
First post as I’m just getting started with Home-Assistant.
I’m trying to send some data to a separate system via JSON-RPC.
This is an extract of my config file:
shell_command:
domotiganesthumidity: curl -sS -X POST -H "Content-Type:application/json" -H "Accept:application/json" -d '{"jsonrpc":"2.0", "method":"device.set", "params":{"device_id":122, "valuenum":"2", "value":"{{sensor.hallway_thermostat_humidity}}"}, "id":122}' SERVERIPADDRESS:9090
automation:
alias: Update Nest Temp
trigger:
platform: time
seconds: '/30'
action:
service: shell_command.domotiganesthumidity
And this is what I get when it runs: (preformatted text doesn’t seem to work for this)
17-01-21 14:25:00 homeassistant.components.shell_command: Error rendering command template: UndefinedError: 'sensor' is undefined
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/homeassistant/helpers/template.py", line 99, in async_render
return self._compiled.render(kwargs).strip()
File "/usr/local/lib/python3.4/dist-packages/jinja2/environment.py", line 1008, in render
return self.environment.handle_exception(exc_info, True)
File "/usr/local/lib/python3.4/dist-packages/jinja2/environment.py", line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.4/dist-packages/jinja2/_compat.py", line 37, in reraise
raise value.with_traceback(tb)
File "<template>", line 1, in top-level template code
File "/usr/local/lib/python3.4/dist-packages/jinja2/sandbox.py", line 385, in getattr
value = getattr(obj, attribute)
jinja2.exceptions.UndefinedError: 'sensor' is undefined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/homeassistant/components/shell_command.py", line 52, in service_handler
rendered_args = args_compiled.render(call.data)
File "/usr/local/lib/python3.4/dist-packages/homeassistant/helpers/template.py", line 86, in render
self.hass.loop, self.async_render, kwargs).result()
File "/usr/lib/python3.4/concurrent/futures/_base.py", line 402, in result
return self.__get_result()
File "/usr/lib/python3.4/concurrent/futures/_base.py", line 354, in __get_result
raise self._exception
File "/usr/local/lib/python3.4/dist-packages/homeassistant/util/async.py", line 167, in run_callback
future.set_result(callback(*args))
File "/usr/local/lib/python3.4/dist-packages/homeassistant/helpers/template.py", line 101, in async_render
raise TemplateError(err)
homeassistant.exceptions.TemplateError: UndefinedError: 'sensor' is undefined
if I replace {{sensor.hallway_thermostat_humidity}}
with a numeric value (like 45) it all works fine.
Q: How do I parse the humidity value as a parameter to the command?