voluptuous.error.MultipleInvalid: expected int for dictionary value @ data['kelvin']

Hi All,

HA 2020.12.1

I get this error and I can’t find why… Here log, below the automation:

2020-12-23 17:28:55 ERROR (MainThread) [homeassistant.components.automation.motion_detection_bathroom_on_off] While executing automation automation.motion_detection_bathroom_on_off
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 404, in async_trigger
    await self.action_script.async_run(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1026, in async_run
    await asyncio.shield(run.async_run())
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 242, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 250, in _async_step
    await getattr(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 457, in _async_call_service_step
    await service_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1399, 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['kelvin']

in homeassistent.yaml file I have this:

legacy_templates: false

Here the automation

- alias: "Motion Detection - Bathroom On Off"
  mode: restart
  trigger:
    - platform: state
      entity_id: binary_sensor.zwave2mqtt_nodeid_88_contact

  variables:
    goodnight: switch.scene_goodnight
    motion_bathroom: binary_sensor.zwave2mqtt_nodeid_88_contact
    adaptive: "{{ states('sensor.adaptive_lighting_color_temperature')| round(0) }}"

  condition: "{{ is_state('switch.bathroom', 'off') }}"

  action:
    - service: light.turn_on
      data:
        entity_id: light.bathroom_all
        brightness_pct: >-
          {% if states(goodnight) == 'on' and states(motion_bathroom) == 'on' %} 50
          {% elif states(goodnight) == 'off' and states(motion_bathroom) == 'on' %} 100
          {% else %} 0
          {% endif %}
        kelvin: "{{ adaptive }}"

    - service: mqtt.publish
      data:
        topic: "homeassistant/ha_motion/bathroom"
        payload: "{{ 1 if is_state(motion_bathroom, 'on') else 0 }}"
adaptive: "{{ states('sensor.adaptive_lighting_color_temperature')|int }}"

Thats it? Im a noob, what is the difference? :slight_smile:

The error said the kelvin field needed an int - you were rounding a string.

Ok. thanks… :smiley:

1 Like