Nah you still have all those escapes and newlines in there (and you didn’t format the code).
Is this how you pasted?
Nah you still have all those escapes and newlines in there (and you didn’t format the code).
Is this how you pasted?
Yeah the “\” and “\n” characters. Where are you copying the automation code from?
I apologize, I’m a literal wombat sometimes.
Yeah, I think you have some issues there with wayward escape characters. Did you copy the RAW code from github?
Ok, see if it is reposted properly above. Yaml is going to be the death of me.
Much better. In your original post you had notify.mobile_app_weston
as the service call. In the automation you posted you have notify.notify
as the service call.
Updated the choose to if. (If is a new thing and is prefereable here. Need to update the git!)
Also I shortened the entity id list template. If you want to use the name like you asked about before you have to go back to the old way and expand the list.
Try this. Copy and paste the whole thing.
automation:
- alias: Unavailable Entities Notification
description: "Create persistent notification if there are unavailable entities, dismiss if none."
trigger:
- platform: state
entity_id: sensor.unavailable_entities
to: ~
condition:
- condition: template
value_template: |
{{ is_number(trigger.from_state.state)
and is_number(trigger.to_state.state) }}
action:
- if:
- condition: numeric_state
entity_id: sensor.unavailable_entities
below: 1
then:
- service: persistent_notification.dismiss
data:
notification_id: unavailable_entities
else:
- service: persistent_notification.create
data:
title: Unavailable Entities
message: "- {{ state_attr('sensor.unavailable_entities','entity_id')|join('\n- ') }}"
notification_id: unavailable_entities
- service: notify.notify
data:
title: Unavailable Devices
message: "- {{ state_attr('sensor.unavailable_entities','entity_id')|join('\n- ') }}"
Just so you realize how that trigger works - this will only trigger once, when the sensor goes above 0 for the first time. It won’t trigger if more entities become unavailable unless the sensor goes back to 0 first.
If you want notifications every time any sensor goes on or offline, you’ll have to adjust the trigger.
Yeah, I would prefer the weston one like you ended up doing. Ahhh, I follow you. I would have never gotten that, just don’t understand alot of the programming yet. I’m in a technical career field but I’m a monkey with programming, 3 lines take me 3 hours. haha. Thank you and I’m testing it now. And I follow you on the id list template. I think.
I am getting a “bad indentation” red exclamation when pasting to file editor add on
The entity_id attribute of sensor.unavailable_entities is already a list object of the entity id’s so there is no point in expanding it and creating a list of the entity id’s - you already had that!
If you wanted a list of a different attribute like the name (map(attribute=‘name’) you have to expand the object and remap it and recreate the list.
Clear as mud?
I follow you and yeah, that is more than likely what I would like because I really only plan on using this on the critical things like water leak sensor/ contact sensors for exterior doors etc.
I went back and reposted with the automation:
section header. Maybe that will help you place it in the right spot.
Oh definitely, like the darkest mud you’ve ever seen. haha. I will spend some time on reading over this and hopefully understand/ figure it all out over the next few days. haha.
Let me know how you make out with the automation. I don’t use the File Editor so I’m not much help there. I’d look into setting up Samba and VSCode… much easier once you figure it out.
Why are there “-” at the start of your “alias” but not at the start of all of the ones in my file editor automations.yaml file?
D’oh. There’s no ID! You didn’t include it when you originally posted the automation.
I forgot you’re not posting into the automation UI editor which automatically puts an id.
Replace the alias line with this.
- id: '3463875679457356848'
alias: Unavailable Entities Notification
*sighhh, it still doesn’t seem to be working. I’ve switched over to Studio Code Server. I got the Devil to work, my lord. spacing/ whitespace is a disaster in this programming language. Maybe it’s all of them but this is my first experience in these things.
Well you did kinda jump right into the fire
Glad you got 'er goin.
I’m packing it in tonight but when you realize what I meant by this and want to change it hit me up if you don’t get it figured out yourself.
I appreciate your willingness to help me with this especially since I’m just completely new to all of it and you were literally starting out in the negative with me–not even ground zero-- (I’m an engineer by trade but I play with bridges for a living so this coding blows my mind, never knew leading spaces could be such a nightmare in some languages, haha) and I agree with how you worded that. I’ll definitely have to digest some of this stuff to even understand it all and I would say your right, once I understand what is going on, I may end up coming back to you and being like “Onnnnn second thought, can this be done”. Let’s give that a little bit though. I would say you were blue in the face after dealing with this monkey for that little bit last night.
Thank you for offering your help, I really do appreciate it, these devices were really some of the only things (water sensor/ door sensors) I have in my house that were kind of “mission critical” and I just would like to make sure they were as bullet proof as possible (or as capable as I/ we ccould make them with a little help).