Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 99172

Strange error about script, and attribute lower, neither of which are used in automation

$
0
0

@Mariusthvdb wrote:

please check with me…I am lost :wink: Ive made an error in the bottom line (referencing the trigger.to_state, while I should have referenced the binary_sensor in the condition. Having said that, I completely fail to see why the I see this error:


about an attribute lower in the script execution using this automation:
  - alias: Uv Alert
    id: 'Uv Alert'
    trigger:
      platform: state
      entity_id: sensor.dark_sky_uv_index
    condition:
      condition: state
      entity_id: binary_sensor.uv_alert
      state: 'on'
    action:
      service: notify.notify
      data_template:
        title: >
         {{as_timestamp(now())|timestamp_custom('%X')}} : Uv Alert: {{trigger.to_state.state}}
        message: >
          {% set mapper = {'1':'Zeer laag','2':'Zeer laag','3':'Laag',
                           '4':'Laag','5':'Matig','6':'Matig',
                           '7':'Hoog','8':'Hoog','9':'Zeer hoog',
                           '10':'Zeer hoog'} %}
          {{trigger.to_state.name}} {{'verbeterde'
          if trigger.to_state.state|int < trigger.from_state.state|int
           else 'verslechterde'}} from {{trigger.from_state.state}} -
           mapper[trigger.from_state.state] to
            {{trigger.to_state.state}} - mapper[trigger.to_state.state].
            Maximaal {{state_attr(trigger.to_state, 'Maximaal in zon')}}

more-info on the logged error in 2 images because of too large for my screen:

If anyone can spot the attribute lower…

btw, this is the referenced binary_sensor in the condition, but, since it is not used in the bottom notification template that shouldn’t even matter.

Shouldn’t I simply get an error about trigger.to_state not having the attribute ‘Maximaal in de zon’ ?

binary_sensor:

  - platform: template
    sensors:
      uv_alert:
        friendly_name: Uv Alert
        value_template: >
          {{states('sensor.dark_sky_uv_index')|int > 4}}
        attribute_templates:
          Uv index: >
            {{states('sensor.dark_sky_uv_index')|int}}
          Omschrijving: >
            {% set index = states('sensor.dark_sky_uv_index') %}
            {% set mapper = {'1':'Zeer laag','2':'Zeer laag','3':'Laag',
                   '4':'Laag','5':'Matig','6':'Matig',
                   '7':'Hoog','8':'Hoog','9':'Zeer hoog',
                   '10':'Zeer hoog'} %}
            {{mapper[index] if index in mapper else 'unknown'}}
          Maximaal in zon: >
            {% set index = states('sensor.dark_sky_uv_index') %}
            {% set mapper = {'1':'100 - 50','2':'100 - 50','3':'35 - 25',
                   '4':'35 - 25','5':'25 - 15','6':'25 - 15',
                   '7':'15 - 10','8':'15 - 10','9':'minder dan 10',
                   '10':'minder dan 10'} %}
            {{mapper[index] if index in mapper else 'unknown'}} minuten.
        device_class: safety

thanks for having a look

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 99172

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>