SgtBatten / HA_blueprints

Somewhere to store automation blueprints
204 stars 78 forks source link

[Issue]: State filter with input_select entity ends in "TEST : FAIL" #286

Closed LHommeQuAVuLOurs closed 1 month ago

LHommeQuAVuLOurs commented 1 month ago

Description

Hello @SgtBatten and thank you very much for this wonderful blueprint !

I may have misunderstood the "state filter" feature so I don't know if the following behavior is a bug or the result of a misusage.

I've configured my automation with a state filter based on an input select. It should notify my if the input_select is in state "Absent" or "Nuit" (away or night) but the debug shows "TEST: FAIL" :

State Filter: state filter toggle on: True, state filter entity: input_select.mode_de_surveillance, required states: ['Absent', 'Nuit'], TEST: FAIL

image

The same automation with the state filter disabled works just fine. I've tried with a single value but the test still fails I've tried in lowercase but the test still fails.

Am I missing something obvious ?

Have a good day !

Version

0.12.0.4d

Automation Config

alias: Frigate - xxx notif
description: ""
use_blueprint:
  path: SgtBatten/Stable.yaml
  input:
    camera: camera.xxx
    notify_device: xxx
    title: Surveillance
    message: >-
      {{ label }} {{ 'immobile' if loitering else 'détécté' }} par la caméra  {{
      camera_name }} {% if enteredzones %}({{ enteredzones | join(', ') |
      replace('_',' ') }}){% endif %}.
    attachment: snapshot.jpg?bbox=1&crop=1
    update_thumbnail: true
    video: ""
    icon: mdi:cctv
    android_auto: true
    sticky: true
    custom_action_manual:
      - action: light.turn_on
        metadata: {}
        data: {}
        target:
          entity_id:
            - light.xxx
    button_1: Light
    url_1: custom-{{ camera }}
    url_2: >-
      {{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/{{camera}}/clip.mp4
    button_2: Clip
    url_3: >-
      {{base_url}}/api/camera_proxy_stream/camera.{{trigger.payload_json['after']['camera']
      | lower | replace('-','_')}}?token={{state_attr( 'camera.' ~ camera,
      'access_token')}}
    button_3: Live
    update_sub_label: false
    alert_once: true
    labels:
      - person
    tap_action: "{{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/snapshot.jpg"
    channel: Frigate
    state_filter: true
    state_entity: input_select.mode_de_surveillance
    state_filter_states:
      - Absent
      - Nuit
    debug: true

Frigate Config

No response

Any other relevant information

No response

SgtBatten commented 1 month ago

A couple of idea.

Try with lower case absent and nuit

If that still doesnt work, try the english terms, away and night.

LHommeQuAVuLOurs commented 1 month ago

Thank you for your answer I already tried in lowercase without success, and just to be sure I tried the english version but as expected it's still the same.

The input_select is a "helper" created by myself with custom values :

image

SgtBatten commented 1 month ago

Ahh Interesting.

I force the states to be lower case for the test because normally entities produce lower case states. Let me try something and give you a new version

SgtBatten commented 1 month ago

Please manually update your blueprint to this version and try it https://github.com/SgtBatten/HA_blueprints/blob/d661611fc8f925a625b787686f8dec636a262081/Frigate_Camera_Notifications/Stable.yaml

LHommeQuAVuLOurs commented 1 month ago

Ok I think I understand what you mean : you test (current entity state = lowercase(parameter)) ? If so, it can't work because I've configured my states with an uppercase.

As a workaround, I try updating my input_select values to "absent" instead of "Absent" and the filter works now. However, I think that for safety you should lowercase each side of the test (and it's prettier in a dashboard :D).

Thank you for your help understanding the priblem !

SgtBatten commented 1 month ago

I have done lowercase on both sides in the version above. You can try it with capital states for your helper

LHommeQuAVuLOurs commented 1 month ago

Ok just saw your fix, however I'm kind of new with blueprints, how do I manually update ? I just copy-paste the new Yaml in the blueprint file ? image

SgtBatten commented 1 month ago

yes paste it over the top and then go to developer tools and reload automations image

LHommeQuAVuLOurs commented 1 month ago

Perfect ! It's doing the job now :) Thank you !