Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting type mismatches on recent versions #52

Open
scstraus opened this issue Nov 30, 2020 · 2 comments
Open

Getting type mismatches on recent versions #52

scstraus opened this issue Nov 30, 2020 · 2 comments

Comments

@scstraus
Copy link

scstraus commented Nov 30, 2020

Hi, I think the move to allow more types in hass is causing some problems with the variables component. This automation used to work, but no longer does on .118.4. I'm getting this in the logs:

2020-11-30 10:46:42 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event automation_triggered[L]: name=DPD state change, entity_id=automation.dpd_state_change, source=state
of sensor.dpd_packages_coming_today>
2020-11-30 10:46:42 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.dpd_state_change, old_state=<state automation.dpd_state_chang
e=on; last_triggered=2020-11-25T11:32:13.537553+01:00, mode=single, current=0, id=dpd_state_change, friendly_name=DPD state change @ 2020-11-28T00:18:08.955419+01:00>, new_state=<s
tate automation.dpd_state_change=on; last_triggered=2020-11-30T10:46:42.997153+01:00, mode=single, current=1, id=dpd_state_change, friendly_name=DPD state change @ 2020-11-28T00:18
:08.955419+01:00>>
2020-11-30 10:46:43 INFO (MainThread) [homeassistant.components.automation.dpd_state_change] DPD state change: Running automation actions
2020-11-30 10:46:43 INFO (MainThread) [homeassistant.components.automation.dpd_state_change] DPD state change: Executing step call service
2020-11-30 10:46:43 DEBUG (MainThread) [homeassistant.core] Invalid data for service call variable.set_variable: {'variable': 'dpd_variable', 'attributes_template': {'from': 'NOREP
                                                                                                         ek'}, 'value_template': 'Delivery'}
                                                                                              íme balíÄ
[email protected]', 'date': 'Mon, 30 Nov 2020 10:42:27 +0100', 'subject': 'DPD Kurýr: Dnes Vám doruÄ
2020-11-30 10:46:43 ERROR (MainThread) [homeassistant.components.automation.dpd_state_change] DPD state change: Error executing script. Invalid data for call_service at pos 1: temp
late value should be a string for dictionary value @ data['attributes_template']
2020-11-30 10:46:43 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.dpd_state_change, old_state=<state automation.dpd_state_chang
e=on; last_triggered=2020-11-30T10:46:42.997153+01:00, mode=single, current=1, id=dpd_state_change, friendly_name=DPD state change @ 2020-11-28T00:18:08.955419+01:00>, new_state=<s
tate automation.dpd_state_change=on; last_triggered=2020-11-30T10:46:42.997153+01:00, mode=single, current=0, id=dpd_state_change, friendly_name=DPD state change @ 2020-11-28T00:18
:08.955419+01:00>>
2020-11-30 10:46:43 ERROR (MainThread) [homeassistant.components.automation.dpd_state_change] While executing automation automation.dpd_state_change
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 433, in async_trigger
    await self.action_script.async_run(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1010, in async_run
    await asyncio.shield(run.async_run())
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 245, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 253, in _async_step
    await getattr(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 460, in _async_call_service_step
    await service_task
  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/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: template value should be a string for dictionary value @ data['attributes_template']

This is the automation in question:

- id: dpd_state_change
  alias: 'DPD state change'
  initial_state: 'true'
  trigger:
    platform: state
    entity_id: sensor.dpd_packages_coming_today
  condition:
    condition: state
    entity_id: 'sensor.dpd_packages_coming_today'
    state: 'Delivery'
  action:
    service: variable.set_variable
    data:
      variable: dpd_variable
      attributes_template: >
        {
          "from": "{{ state_attr('sensor.dpd_packages_coming_today', 'from') }}",
          "date": "{{ state_attr('sensor.dpd_packages_coming_today', 'date') }}",
          "subject": "{{ state_attr('sensor.dpd_packages_coming_today', 'subject') }}"
        } 
      value_template: "{{ states('sensor.dpd_packages_coming_today')}}"
@Mariusthvdb
Copy link

#47

@scstraus
Copy link
Author

Thanks Marius. Sorry I missed that one. Will try suggestions from there and probably close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants