Numeric State Error

Hi.

I have an automation which tells me the travel time to my work.

alias: aTrafik - Evden İşe Duyuru
description: ''
trigger:
  - platform: numeric_state
    entity_id: sensor.google_ev_is
    above: '36'
    below: '45'
    id: '45'
  - platform: numeric_state
    entity_id: sensor.google_ev_is
    above: '1'
    below: '35'
    id: '35'
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id: '45'
        sequence:
          - service: notify.alexa_media
            data:
              target: media_player.everywhere
              message: Traffic to work is less then 45 minutes
              data:
                type: announce
          - service: notify.telegrambot
            data:
              message: Trafik 45dk'nın altına düştü.
              title: Google Trafik
      - conditions:
          - condition: trigger
            id: '35'
        sequence:
          - service: notify.alexa_media
            data:
              target: media_player.everywhere
              message: Traffic is less then 35 minutes
              data:
                type: announce
          - service: notify.telegrambot
            data:
              message: Trafik 35dk'nın altına düştü.
              title: Google Trafik
    default: []
mode: single
The code works just fine. But ı have a little problem. If the current traffic duration is 44 and my interval is between 36 - 45 it does not run when I enable the automation. But if numeric state is 46 and drops to 44 then it runs. Is there a way to get it run even if the numeric state(current traffic duration) is the same with the given interval (for example 36-45). 
trigger:
  - platform: template
    value_template: "{{ 36 < states('sensor.google_ev_is')|float(0) < 45 }}"
    id: '45'
  - platform: template
    value_template: "{{ 1 < states('sensor.google_ev_is')|float(0) < 35 }}"
    id: '35'

That does what you asked for, and will trigger whenever the sensor value changes. The trigger will not fire if the sensor is between 35 and 36 inclusive. Perhaps consider using this for the first template, or adjust as you see fit:

    value_template: "{{ 35 <= states('sensor.google_ev_is')|float(0) < 45 }}"

Thank you very much for the reply. This is not I am looking for. Let me give an example.

lets say currently traffic to my work is 41 minutes exactly. My automation’s first trigger have values between 36-45. At that moment if I disable and re enable the automation in a few seconds nothing happens. I want to connect this automation to a boolean and when I turn on the boolean the automation will enable as well. And at that moment because the traffic is 41 minutes I should get the the warnings in the action part. But unfortunately nothing happens.

OK If I understand you correctly you are turning this automation on and expecting when you do, to have the relevant announcement based on your triggers…correct?

If that is the case then I would think you are looking for a script and not an automation. As turning the automation on will not trigger it, it will simply sit and wait for any of the triggers to become active before proceeding and the numerical triggers will only trigger when the value of the sensor crosses across one of the values. For example your 2nd trigger will only trigger if the value changes to above 1 from below 1 or goes from above 35 to below 35.

Were as a script can be triggered manually and you can us multiple choose actions each with individual ranges and with the correct corresponding announcements.

Thank you very much for your interest. I now understand how this works but I still find it useless. Lets say the traffic takes about 43 minutes, then I turn on the automation. As for an condition I have traffic time between 35 and 45. So when turning on it should announce that traffic time matches first option. Instead it is waiting other option to occur which is traffic time between 1 - 35. If it gets to that value then it announces. For my opinion it should announce the first one and then wait for a value change.

Anyway I solved it with creating separate automations. Beside the above automation I have also created another one which immediately announces current traffic time. This gives me an info about the current traffic time. If it suits my needs I will go out. If not I will wait for the second announcement.

Traffic button is my automation.

When I turn it on

First it announces current traffic time with a template and at the end it becomes disabled.

Second my time interval automation starts to function with different intervals. It continuously checks the traffic status and informs me on Alexa and Telegram when certain criterias meet. But it has a condition. It will only trigger when the boolean is on. And when I decide to leave I turn off the boolean. So this cycle wont be active again until I turn on the boolean.

Rossk thank you very much for your help.

Ok glad you got it sorted but I still think you misunderstand automations and triggers.

If you are pressing a front end button to announce some states then I still think a better use would be a script.

An automation is simply a script with triggers that trigger automatically - hence its automated.

You are trying to use triggers like conditions in your original automation and that is why you “find it useless”

Look are the official documentation for numeric triggers:

Numeric state trigger

Fires when the numeric value of an entity’s state (or attribute’s value if using the attribute property, or the calculated value if using the value_template property) crosses (and only when crossing) a given threshold.