I’m trying to setup a command line sensor, and I’m getting some errors in the log that I don’t understand. I was following instructions in this thread about motion sensing with IP cameras, and I’m using the same syntax as he is, and it appears to match the documentation:
# Camera motion Sensors
- platform: command_line
name: Ian Motion
command: "python3 /home/hass/foscam.py 'getMotionAlert' '192.168.1.142' 'username' 'password'"
value_template: '{{ value == "2" }}'
scan_interval: 2
In the log file, there’s this:
16-10-31 16:05:12 homeassistant.components.sensor.command_line: Command failed: python3 /home/hass/foscam.py 'getMotionAlert' '192.168.1.142' 'username' 'password'
16-10-31 16:05:12 homeassistant.components.sensor: Error while setting up platform command_line
Traceback (most recent call last):
File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 151, in _async_setup_platform
entity_platform.add_entities, discovery_info
File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
yield self # This tells Task to wait for completion.
File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
value = future.result()
File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
raise self._exception
File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
result = self.fn(*self.args, **self.kwargs)
File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/sensor/command_line.py", line 45, in setup_platform
add_devices([CommandSensor(hass, data, name, unit, value_template)])
File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/sensor/command_line.py", line 60, in __init__
self.update()
File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/sensor/command_line.py", line 84, in update
value, 'N/A')
File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/helpers/template.py", line 110, in render_with_possible_json_value
error_value).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 "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/util/async.py", line 166, in run_callback
future.set_result(callback(*args))
File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/helpers/template.py", line 127, in async_render_with_possible_json_value
variables['value_json'] = json.loads(value)
File "/usr/lib/python3.4/json/__init__.py", line 312, in loads
s.__class__.__name__))
TypeError: the JSON object must be str, not 'NoneType'
It appears to be crapping out on the value piece, but I’m not sure why.