Where to employ the fresh devtools.template code

1 Like

Also

That configuration is not possible if cover.global does not exist. Make these into helpers entities.

1 Like

okay changed the capitals.

like this then?

Yep. Just create a helper for each global item. Then you can control the global item through the UI without modifying your config and they will persist through shutdown and startup.

1 Like

So i created this one:

and try to fill it with this code:

#Max Temp um 14 Uhr
  - trigger:
      - platform: time_pattern
        # This will update every night at 6 am
        hours: "6"
        minutes: "0"
    action:
      - service: input_number.set_value
        data:
          entity_id: input_number.cover_max_temp_today
          value: "{{ state_attr('weather.climacell_hourly','forecast') | selectattr('datetime','eq',as_timestamp(today_at('14:00'),0) | timestamp_utc(0)) | map(attribute='temperature') | join | float(0) }}"

but i get this error from my log

Logger: homeassistant.config
Source: config.py:454
First occurred: 18:20:37 (1 occurrences)
Last logged: 18:20:37

Invalid config for [template]: [action] is an invalid option for [template]. Check: template->action. (See /config/templates.yaml, line 69).

any advice, what Im doing wrong?

You’re putting that in the template section. That’s an automation.

I have to say, this is probably one of the most unique helping situations I’ve been in. You’re nailing the template stuff but missing the basic yaml stuff. I’m sure you’ll nail the yaml stuff in no-time because templating is by far the hardest thing in HA.

1 Like

Thanks again petro.

1 Like

I got this now in automations.yaml

- id: '1643913219268'
  alias: Max Temp 14 Uhr
  description: ''
  trigger:
  - platform: time
    at: 06:00
  condition: []
  action:
  - service: input_number.set_value
    data:
      value: '{{ state_attr(''weather.climacell_hourly'',''forecast'') | selectattr(''datetime'',''eq'',as_timestamp(today_at(''14:00''),0)
        | timestamp_utc(0)) | map(attribute=''temperature'') | join | float(0) }}'
    target:
      entity_id: input_number.cover_max_temp_today
  mode: single

and it seams to work. thanks a lot

1 Like

back to the template thing:

i have this (only this) in customize.yaml

# values for roller shutter script

cover.eg_kueche:      # individual window shading settings
    window_direction: 180             # direction the window is facing: default 180 = south
    azimuth_limit_low: 135            # lover deviation from window direction from which shading is required: default 45 (positive value, also its negative of the window!)
    azimuth_limit_high: 225           # upper deviation from window direction up to wich shading is required: default 45
    window_tilt: 0                    # deviation from vertical if e.g. roof window (a wall window is 0° deviation)
    window_height: 1000               # height of window in mm
    window_wall_thickness: 400        # width of wall including inside window sill in mm
    window_sun_strake:  100           # acceptable width of sun streaks (AWS) in mm
    window_min_elevation_shading_active: 15 # from which elevation onward shading is required
    roller_shutter_depth: 50          # depth of the shutter from outside wall
    roller_shutter_start_shading: 98  # start shading in % of roller shutter
    roller_shutter_full_shading: 5    # fully shaded in % of roller shutter
    roller_shutter_catdoor: 5         # shutter max close setting for cat door or to prevent lock out from terrace door
    roller_shutter_catdoor_time:      # fixed offset time to close the shutter (catch up with the others), if "" then it will never fully close, except by manuall operation.
    roller_shutter_catdoor_active: "false" # if ture, catdoor function is active, if not, normal opeartion will be executed.
    roller_shutter_max: 68            # formula needs to be build. from which elevation shading is no longer required because the wall itself provides shading
    window_awning: "false"                   # awing available for this window (prefere awning is a global setting), if true, roller shutter will not do any shading work.
    shading_paused: "false"           # can be true, false and time, time reativates after the time of automation_pause_time
    open_on_window_open: "false"               # false will prevent automatic window opening during closed roller shutter, true will rise the roller shotter to slotted if window is opened (false will not on manuel windows).

and i have this in sensors.yaml

# roller-shutter EG-Küche 
- platform: template
  sensors:
    cover_eg_kueche_shading_pos_1:
      value_template: >-
        {% set azimuth = states('sensor.test_sun_azimuth') | float(0) %}
        {% set elevation = states('sensor.test_sun_elevation') | float(0) %}
        {% set window_direction = states('sensor.cover_eg_kueche.window_direction') | float(0) %}
        {% set azimuth_limit_low = states('sensor.cover_eg_kueche.azimuth_limit_low') | float(0) %}
        {% set azimuth_limit_high = states('sensor.cover_eg_kueche.azimuth_limit_high') | float(0) %}
        {% set window_tilt = states('sensor.cover_eg_kueche.window_tilt') | float(0) %}
        {% set window_height = states('sensor.cover_eg_kueche.window_height') | float(0) %}
        {% set window_wall_thickness = states('sensor.cover_eg_kueche.window_wall_thickness') | float(0) %}
        {% set window_sun_strake = states('sensor.cover_eg_kueche.window_sun_strake') | float(0) %}
        {% set window_depth_roller_shutter = states('sensor.cover_eg_kueche.window_depth_roller_shutter') | float(0) %}
        {% set roller_shutter_start_shading = states('sensor.cover_eg_kueche.roller_shutter_start_shading') | float(0) %}
        {% set roller_shutter_full_shading = states('sensor.cover_eg_kueche.roller_shutter_full_shading') | float(0) %}
        {% set roller_shutter_catdoor = states('sensor.cover_eg_kueche.roller_shutter_catdoor') | float(0) %}
        {% set roller_shutter_max = states('sensor.cover_eg_kueche.roller_shutter_max') | float(0) %}
        {% set window_min_elevaiton_shading_active = states('sensor.cover_eg_kueche.window_min_elevaiton_shading_active') | float(0) %}

        {% if (window_direction - azimuth_limit_low) < azimuth < (window_direction + azimuth_limit_high) and elevation < roller_shutter_max %}
          {% set shading = "true" %}
        {% else %}
          {% set shading = "false" %}
        {% endif %}
        {% if shading == "true" and elevation > window_min_elevaiton_shading_active %}
          {{ ((window_height + window_wall_thickness + window_sun_strake)*(tan((elevation - window_tilt) * pi / 180) / window_height * 10) | float(0)) | round(0) }}
        {% elif shading != "true" and elevation > window_min_elevaiton_shading_active %}
          {{ window_min_elevaiton_shading_active | float(0)}}
        {% elif elevation < -6 %}
          {{ '0' | float(0) }} 
        {% elif -6 < elevation < 0 %}
          {{ '10' | float(0) }} 
        {% else %}
          {{ '100' | float(0) }} 
        {% endif %}

the output to cover_eg_kueche_shading_pos_1 works on everything that does not relay on the input from customize.yaml

so i made something wrong in calling the variables into the sensors.yaml

whos able to point me to my error? for the life of me, i cant figure that one out.

edit: found a typo, but that was not the problem

I think there is something wrong with my customize.yaml, the entity is not created. however if i change something like removing the decimal point between cover and eg_kueche I get an error on config check. so its included, but why ever it does not create an entity with the set values.