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

Not working automations with triggers and templates

$
0
0

@Ninuss wrote:

I’m using Hassio on RPi to make some automations. I’m new in domotics, and in Home Assistant, near 7 mounth of study on it. Well, i don’t known how to make any automation in automatic… I don’t known where is my fault. I read all documentation and all forums, I searched with google and tried all possible solutions… but there is some strange thing, that I do or I don’t do, that is wrong. I’ll explain now. I want to create a persistent notification when a sensor attribute is below 1 (numeric state). The sensor name is “rifiuti_organici” the attribute to check is “days”. The “days” is a number that go from any value to 0. I want to trigger my automation when this sensor attribute go to 1 and lower and show a persistent notification for this happening. I used 1 sensor but I want to use many others similar in one automation. Every sensor, even this one tested named “rifiuti_organici”, has setted friendly_name attribute. For this tested the friendly_name is “Rifiuti Organici”. This is the automation test (I’m using Automation Editor included in Hassio):

- id: '1574810504844'
  alias: TestingRDRSU
  description: ''
  trigger:
    - platform: template
      value_template: '{{ states.sensor.rifiuti_organici.attributes.days|int < 2 }}'
  condition: []
  action:
    - data:
        message: "Triggered by: {{state_attr(trigger.to_state.entity_id, 'friendly_name')}}
        {% if trigger.to_state.state == 'on' %} 
        ON
        {% elif trigger.to_state.state == 'off' %}    
        OFF 
        {% else %}
        Error for trigger status. 
        {% endif %}

        1: {{ trigger.from_state }}
        2: {{ trigger.to_state }}
        3: {{ trigger.from_state.attributes.friendly_name }}
        4: {{ trigger.to_state.attributes.friendly_name }}
        5: {{ trigger.from_state.entity_id }}"
      notification_id: RDRSU
      title: Raccolta Differenziata
      service: persistent_notification.create

When I activate manually this automation and the sensor has days=1 or days=0, the persistent notification appear with the same message that I wrote in Automation Editor, without any change on content…
Where is the wrong thing?
I tried changing " with ’ … nothing
I changed data: with data_template: with Configurator plugin… the automation didn’t run even manually…
I tried all…
What I can do?

There is a strange behaviour when in Automation Editor I press the space bar on keyboard… it don’t add a space, but try to jump at end of page.
There are some bugs to solve yet? Or my system don’t work?
Strange…

Thanks in advances for your kind replies.

Posts: 7

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 95486

Trending Articles



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