I’m trying to get a negative condition to work in my automation, so I have been playing with templates…
However, whenever I try to check that the configuration is valid (from the Server Controls page), nothing really happens (the Check Configuration’s “busy status” thing just keeps rotating.)
Looking at the log, I’m causing this error:
2020-05-18 22:26:16 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 418, in start
resp = await task
File "/usr/local/lib/python3.7/site-packages/aiohttp/web_app.py", line 458, in _handle
resp = await handler(request)
File "/usr/local/lib/python3.7/site-packages/aiohttp/web_middlewares.py", line 119, in impl
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/real_ip.py", line 39, in real_ip_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 73, in ban_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 127, in auth_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 125, in handle
result = await result
File "/usr/src/homeassistant/homeassistant/components/config/core.py", line 29, in post
errors = await async_check_ha_config_file(request.app["hass"])
File "/usr/src/homeassistant/homeassistant/config.py", line 830, in async_check_ha_config_file
res = await check_config.async_check_ha_config_file(hass)
File "/usr/src/homeassistant/homeassistant/helpers/check_config.py", line 148, in async_check_ha_config_file
p_validated = component_platform_schema(p_config)
File "/usr/local/lib/python3.7/site-packages/voluptuous/validators.py", line 208, in __call__
return self._exec((Schema(val) for val in self.validators), v)
File "/usr/local/lib/python3.7/site-packages/voluptuous/validators.py", line 283, in _exec
v = func(v)
File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 272, in __call__
return self._compiled([], data)
File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 817, in validate_callable
return schema(data)
File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 272, in __call__
return self._compiled([], data)
File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 594, in validate_dict
return base_validate(path, iteritems(data), out)
File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 386, in validate_mapping
cval = cvalue(key_path, value)
File "/usr/local/lib/python3.7/site-packages/voluptuous/validators.py", line 205, in _run
return self._exec(self._compiled, value, path)
File "/usr/local/lib/python3.7/site-packages/voluptuous/validators.py", line 285, in _exec
v = func(path, v)
File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 635, in validate_sequence
cval = validate(index_path, value)
File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 817, in validate_callable
return schema(data)
File "/usr/src/homeassistant/homeassistant/helpers/config_validation.py", line 732, in key_value_validator
if key_value not in value_schemas:
TypeError: unhashable type: 'collections.OrderedDict'
The yaml / jinja causing the error appears to be simply:
- condition:
condition: template
value_template: "{{ not is_state('input_select.house_mode', 'Away') }}"
removing that, or changing it to a standard state condition, then everything’s good…
IMHO a syntax / coding error appears to be causing quite a fault in the system, which should be at least caught and returned as “Configuration is not right!”
I see that this was occuring recently with This forum post, so perhaps there’s a bug here?
Just for completeness, my actual code is:
- id: 'EveningLampsOnSummer'
alias: Summer Evening Lamps (On)
trigger:
platform: numeric_state
entity_id: sun.sun
value_template: '{{ state.attributes.elevation }}'
below: '4.0'
condition:
- condition: time
after: '17:45'
before: '22:14'
- condition:
condition: template
value_template: "{{ not is_state('input_select.house_mode', 'Away') }}"
action:
- entity_id: switch.hall_socket_1_relay
service: switch.turn_on
Pointers?