So I’ve decided to take the plunge and get this going. I “borrowed” the bulk of your configs and modified them a bit for my use. Took me a bit to get it up and running but am now running into these errors and can’t seem to figure out where I made a wrong turn. I’m hoping you and the others might be able to help me out.
Here are the errors I get:
2017-11-09 13:34:39 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.washer_stopwatch fails
Traceback (most recent call last):
File “/srv/homeassistant/homeassistant_venv/lib/python3.6/site-packages/homeassistant/helpers/entity.py”, line 204, in async_update_ha_state
yield from self.async_device_update()
File “/srv/homeassistant/homeassistant_venv/lib/python3.6/site-packages/homeassistant/helpers/entity.py”, line 307, in async_device_update
yield from self.async_update()
File “/usr/local/lib/python3.6/asyncio/coroutines.py”, line 210, in coro
res = func(*args, **kw)
File “/srv/homeassistant/homeassistant_venv/lib/python3.6/site-packages/homeassistant/components/sensor/template.py”, line 155, in async_update
self._state = self._template.async_render()
File “/srv/homeassistant/homeassistant_venv/lib/python3.6/site-packages/homeassistant/helpers/template.py”, line 116, in async_render
return self._compiled.render(kwargs).strip()
File “/srv/homeassistant/homeassistant_venv/lib/python3.6/site-packages/jinja2/asyncsupport.py”, line 76, in render
return original_render(self, *args, **kwargs)
File “/srv/homeassistant/homeassistant_venv/lib/python3.6/site-packages/jinja2/environment.py”, line 1008, in render
return self.environment.handle_exception(exc_info, True)
File “/srv/homeassistant/homeassistant_venv/lib/python3.6/site-packages/jinja2/environment.py”, line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File “/srv/homeassistant/homeassistant_venv/lib/python3.6/site-packages/jinja2/_compat.py”, line 37, in reraise
raise value.with_traceback(tb)
File “”, line 2, in top-level template code
File “/srv/homeassistant/homeassistant_venv/lib/python3.6/site-packages/jinja2/sandbox.py”, line 427, in call
return __context.call(__obj, *args, **kwargs)
File “/srv/homeassistant/homeassistant_venv/lib/python3.6/site-packages/homeassistant/util/dt.py”, line 192, in get_age
delta = now() - date
TypeError: unsupported operand type(s) for -: ‘datetime.datetime’ and ‘str’
2017-11-09 13:34:39 ERROR (MainThread) [homeassistant.components.sensor.template] Could not render template Washer Status: UndefinedError: ‘options’ is undefined
2017-11-09 13:34:40 ERROR (MainThread) [homeassistant.components.sensor.template] Could not render template Washer Status: UndefinedError: ‘options’ is undefined
2017-11-09 13:34:40 ERROR (MainThread) [homeassistant.components.sensor.template] Could not render template Washer Status: UndefinedError: ‘options’ is undefined
2017-11-09 13:34:40 ERROR (MainThread) [homeassistant.components.sensor.template] Could not render template Washer Status: UndefinedError: ‘options’ is undefined
Both errors just repeat and repeat and repeat and repeat.
And here are the relevant portions of code:
washer_status_is.yaml (input_select):
name: 'Washer Status'
options:
- Idle
- Cleaning
- Power Off
initial: Power Off
icon: mdi:washing-machine
washer_stopwatch_ib.yaml (input_boolean):
name: Washer Stopwatch
initial: off
icon: mdi:timelapse
washer_stopwatch,yaml (sensor template):
- platform: template
sensors:
washer_stopwatch:
friendly_name: 'Wash Cycle Time'
value_template: >
{% if is_state('input_boolean.washer_stopwatch', 'off') %}
{{ relative_time(states.automation.washer_running.attributes.last_triggered) }}
{% elif is_state('sensor.washer_stopwatch', 'unknown') %}
0 seconds
{% else %}
{{ state('sensor.washer_stopwatch') }}
{% endif %}
washer_status.yaml (sensor template):
- platform: template
sensors:
washer_status:
friendly_name: 'Washer Status'
value_template: '{{ options.input_select.washer_status_is.options }}'
And finally, the 2 automations. (not using the power off or error ones just yet)
washer_idle.yaml :
alias: 'Washer Idle'
trigger:
- entity_id: sensor.washer_current_consumption
platform: numeric_state
below: 1
for:
minutes: 3
condition:
condition: and
conditions:
- condition: state
entity_id: 'switch.washing_machine'
state: 'on'
action:
- service: input_select.select_option
data:
entity_id: input_select.washer_status_is
option: Idle
- service: notify.HomeAssistantFE
data:
message: Wash cycle complete; put that shit in the dryer!
title: Wash Cycle Complete
- service: input_boolean.turn_off
entity_id: input_boolean.washer_stopwatch_ib
washer_running.yaml:
alias: 'Washer Running'
trigger:
- entity_id: sensor.washer_current_consumption
platform: numeric_state
above: 5
condition:
condition: and
conditions:
- condition: state
entity_id: 'switch.washing_machine'
state: 'on'
action:
- service: input_select.select_option
data:
entity_id: input_select.washer_status_is
option: Cleaning
- service: input_boolean.turn_on
entity_id: input_boolean.washer_stopwatch_ib
This is my first attempt at a more complex automation and templating so I expect that I’ve really screwed something up here; but for the life of me I just can’t figure it out. I’m hoping some fresh sets of eyes will be able to smack some sense into me.
Thanks!