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

Incorrect type error when !include_dir_named is used in configuration.yaml #2801

Open
3 of 11 tasks
ChrisBaker97 opened this issue Aug 16, 2023 · 3 comments
Open
3 of 11 tasks
Labels
bug Something isn't working

Comments

@ChrisBaker97
Copy link

Parsing configuration.yaml produces errors when template entities are included using !include_dir_named:

Incorrect type. Expected "object".

All works fine, and the configuration passes Home Assistant's YAML validation.

Please include the related YAML code:

sensor:
  - platform: template
    sensors: !include_dir_named template_sensors/

binary_sensor:
  - platform: template
    sensors: !include_dir_named template_binary_sensors/

switch:
  - platform: template
    switches: !include_dir_named template_switches/

A representative file, template_sensors/illumination.yaml:

friendly_name: "Illumination"
unique_id: sensor.illumination
attribute_templates:
  angle: "{{ state_attr('sun.sun','elevation') | float(0.0) }}"
  effective_angle: "{{ state_attr('sun.sun','elevation')|float(0.0) - states('input_number.sun_angle_bias')|float(0.0) }}"
value_template: >-
  {% set elevation = state_attr('sun.sun','elevation') | float(0.0) %}
  {% if elevation > 0.0 %} Day
  {% elif elevation > -6.0 %} Civil Twilight
  {% elif elevation > -12.0 %} Nautical Twilight
  {% elif elevation > -18.0 %} Astronomical Twilight
  {% else %} Night
  {% endif %}
icon_template: >-
  {% set elevation = state_attr('sun.sun','elevation') | float(0.0) %}
  {% if elevation > 0.0 %} mdi:weather-sunny
  {% elif elevation > -18.0 %} mdi:weather-sunset
  {% else %} mdi:weather-night
  {% endif %}

Extension runs in:

  • VS Code for Desktop
  • Hassio Add-on
  • Visual Studio Online
  • Other:

I'm running VS Code on:

  • Windows
  • Mac
  • Linux

I'm accessing my files:

  • From local disk
  • Via remote SSH
  • Smb
  • Other:
@ChrisBaker97 ChrisBaker97 added the bug Something isn't working label Aug 16, 2023
@frenck
Copy link
Collaborator

frenck commented Aug 16, 2023

Yup this may happen and is actually ok to ignore.

Essentially, this statement can be put everywhere. The extension has some logical places to shallow those, but setting them on every single parameter would not make sense either. So, this is a balance game without a solution at this point.

../Frenck

@ChrisBaker97
Copy link
Author

I suppose there's no easy way to borrow HA's code to actually assemble and parse those as if they were part of the configuration.yaml file itself before linting it?

@frenck
Copy link
Collaborator

frenck commented Aug 17, 2023

nope

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants