Issue with the dev

Hi,

I’m trying to make my first blueprint

This simple blueprint will regulate a switch based on a temperature sensor

I have an issue … but I don’t know where is the problem …

Could you help me ?

blueprint:
  name: Heating Virtual Thermostat
  description: Regulating of an electrical heater connected to a switch using a temperature
    sensor
  domain: automation
  input:
    sensor_temperature:
      name: Temperature sensor
      description: This dector will be used for the regulation
      selector:
        entity:
          domain: sensor
          device_class: temperature
    target_switch:
      name: Actuator
      description: Actuator to be controled
      selector:
        target:
          entity:
            domain: switch
  source_url: https://github.com/PITP2/Blueprints/blob/606e2effeb1029072e52f0c8232f9601a841ee9a/Thermostat%20virtuel
trigger:
- platform: numeric_state
  entity_id: !input 'sensor_temperature'
  above: '21'
- platform: numeric_state
  entity_id: !input 'sensor_temperature'
  below: '20'
action:
- choose:
  - conditions:
    - condition: numeric_state
      entity_id: !input 'sensor_temperature'
      below: '20'
    sequence:
    - service: switch.turn_on
      data:
        entity_id: !input 'target_switch'
  - conditions:
    - condition: numeric_state
      entity_id: !input 'sensor_temperature'
      below: '21'
    sequence:
    - service: switch.turn_off
      data:
        entity_id: !input 'target_switch'
  default:
mode: single
> 2020-12-27 16:28:52 INFO (MainThread) [homeassistant.components.automation.heating_virtual_thermostat] Heating Virtual Thermostat: Running automation actions
> 2020-12-27 16:28:52 INFO (MainThread) [homeassistant.components.automation.heating_virtual_thermostat] Heating Virtual Thermostat: Choose at step 1: choice 2: Running automation actions
> 2020-12-27 16:28:52 INFO (MainThread) [homeassistant.components.automation.heating_virtual_thermostat] Heating Virtual Thermostat: Choose at step 1: choice 2: Executing step call service
> 2020-12-27 16:28:52 ERROR (MainThread) [homeassistant.components.automation.heating_virtual_thermostat] Heating Virtual Thermostat: Choose at step 1: choice 2: Error executing script. Invalid data for call_service at pos 1: not a valid value for dictionary value @ data['entity_id']
> 2020-12-27 16:28:52 ERROR (MainThread) [homeassistant.components.automation.heating_virtual_thermostat] Heating Virtual Thermostat: Error executing script. Invalid data for choose at pos 1: not a valid value for dictionary value @ data['entity_id']
> 2020-12-27 16:28:52 ERROR (MainThread) [homeassistant.components.automation.heating_virtual_thermostat] While executing automation automation.heating_virtual_thermostat
> 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 596, in _async_choose_step
>     await self._async_run_script(script)
>   File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 670, in _async_run_script
>     await self._async_run_long_action(
>   File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 419, in _async_run_long_action
>     long_task.result()
>   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/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: not a valid value for dictionary value @ data['entity_id']

Your blueprint defines a Target Selector named target_switch however your automation refers to it like an Entity Selector and not like a Target Selector.

If you use a Target Selector, your automation must refer to it using the target option.

    sequence:
    - service: switch.turn_on
      target: !input 'target_switch'

In addition, I believe there may be an error in the second condition in choose. It uses below: 21 but its matching Numeric State Trigger uses above: 21.

Thank you for your help works fine now :slight_smile: