ih8gates
(Scott Reston)
December 8, 2016, 10:09pm
21
Haven’t tried, but what happens when you test for it with a template trigger?
trigger:
- platform: template
value_template: '{% if (states.persistent_notification.name_of_notification.state) %}true{% else %}false{%endif%}'
edit: @fanaticDavid came to the rescue while I was testing my syntax
silvrr
December 9, 2016, 1:27pm
22
The notification works, however, it does give another notification when you dismiss. Ill have to work on the condition.
Hmmm try removing the single quotes around None
, so:
condition:
- condition: template
value_template: "{{ trigger.to_state.state != None }}"
1 Like
Bob_NL
(Bob Visser)
February 10, 2017, 3:51pm
24
That did the trick
Update: It does create an empty notification (only the title, message is blanc) after dismissing the login failure persistant notification in the frontend which is kind of annoying. Any idea how to dismiss these in silence (or even better: dismiss them at once since I will allready be notified anyway)?
2 Likes
molano
(Arnout Verbeken)
February 10, 2017, 9:51pm
25
Found it.
The condition must be:
condition:
- condition: template
value_template: "{{ trigger.to_state.state != off }}"
Bob_NL
(Bob Visser)
February 13, 2017, 6:36pm
26
Doesn’t work anymore after upgrading to 0.38.2 since there is no entry in the logfile anymore.
Update: same issue on 0.38.3
1 Like
Bob_NL
(Bob Visser)
February 26, 2017, 11:15am
28
Works like a charm on 0.39
metbril
(Robert 🇳🇱🇪🇺)
April 2, 2017, 5:38am
29
I have solved this by adding a value_template
that always subtracts 1 :
- platform: command_line
name: bad_login
command: "grep -c 'Login attempt' /home/homeassistant/.homeassistant/home-assistant.log"
value_template: '{{ value | int - 1 }}'
My sensor reports 0
after a restart and the actual number of bad logins when they occur.
1 Like
silvrr
January 29, 2019, 6:28pm
30
anyone using this be sure to validate that it still works after the 0.86 update. I noticed that persistent_notification.httplogin
has become persistent_notification.http_login
on my configuration which breaks the automation many are using.
(unique content to make the forum not freak out)
1 Like
Thanks a lot. This saved me a huge head ache.
1 Like
caiosweet
(Caiosweet)
August 12, 2020, 4:18pm
34
This discussion is old, but maybe it can still be useful …
to avoid another notification when ignoring… i use this condition…
from your github - pc_security
replace…
condition:
- condition: template
value_template: "{{ trigger.to_state.state != 'None' and trigger.to_state.entity_id is defined}}"
and removed service: persistent_notification.dismiss
belanger
(Euphoric Hacker)
April 12, 2024, 5:46pm
35
FYI the following seems a good workaround just by adding || true
command: ‘grep -c “Login attempt” /config/home-assistant.log || true’