Error in data_template turning on lights

Yes, i know… :slight_smile:

In this case i must rewrite all the templates i have actually?

No, not likely. it only affects certain templates and most people don’t really notice.

I’m using it on 117.3 right now and I only had a few templates that needed conversions and they were all related to a custom component configuration (hass-variables)

Hmmm…I think that’s backwards based on this statement from that post:

I know it’s definitely a bit confusing.

What’s worse is that becxause of a bug in the template editor makes it difficult to test this functionality.

I recommend giving it a try and see what happens.

If i use the template in the model editor i get the right values, so why the script is wrong ???

1 Like

I do have the same problem since 118.3

entity_id: light.garten_oben
brightness: "200"
color_temp: '{{ state_attr("light.wohnzimmer_stlmp_unten","color_temp") |int }}'

Logger: homeassistant.components.websocket_api.http.connection
Source: core.py:1405
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 17:35:41 (5 occurrences)
Last logged: 17:49:43

[1741517536] expected int for dictionary value @ data['color_temp']
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 135, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1405, in async_call
    processed_data = handler.schema(service_data)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/validators.py", line 218, in __call__
    return self._exec((Schema(val) for val in self.validators), v)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/validators.py", line 340, in _exec
    raise e if self.msg is None else AllInvalid(self.msg, path=path)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/validators.py", line 336, in _exec
    v = func(v)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/validators.py", line 215, in _run
    return self._exec(self._compiled, value, path)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/validators.py", line 340, in _exec
    raise e if self.msg is None else AllInvalid(self.msg, path=path)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/validators.py", line 338, in _exec
    v = func(path, v)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py", line 817, in validate_callable
    return schema(data)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py", line 594, in validate_dict
    return base_validate(path, iteritems(data), out)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py", line 432, in validate_mapping
    raise er.MultipleInvalid(errors)
voluptuous.error.MultipleInvalid: expected int for dictionary value @ data['color_temp']

By the way: This works so far:

- service: light.turn_on
              entity_id: light.garten_unten
              data:
                brightness: "250"
                xy_color:
                  - "{{state_attr('wohnzimmer_fenster_oben','xy_color')[0]}}"
                  - "{{state_attr('wohnzimmer_fenster_oben','xy_color')[1]}}"

So what is the difference?
I created an issue on Github #43730

Hi all, does anybody have found a solution for this?
Meanwhile, the code which works so far suddenly throws an error since yesterday evening.
Why yesterday, why not from the beginning? I’m confused.

I believe not. I luckily came across this post after being confronted with the same error. I wanted to dynamically generate the values for rgb_color on a service call for lights on. Eventually this worked;

service: light.turn_on
target:
  entity_id: light.woonkamer_woonkamer_plafond_midden
data:
  rgb_color:
    - "{{ (range(0, 255)|random|int) }}"
    - "{{ (range(0, 255)|random|int) }}"
    - "{{ (range(0, 255)|random|int) }}"
  brightness: 159