Been round the boards for a couple of days with this one but can’t figure it out.
Short question: is it possible to include the script name in the body of a notify action.
Context: I have a series of WiFi plugs which jump on/off the network (another problem to sort out another day) so have been creating more robust scripts triggered by automation’s to handle these. Basically, if they don’t turn on at first attempt I’m trying again (and again) until finally giving up. When I give up, I’m pinging a message to my phone with the state of the devices so I can go and turn the thing off and back on (yes, I know I need better devices!).
So two things I’m sure people will point out - is this overkill, yes probably but important for me to be able to get to the device and sort it out before the family complains and block any further evolution of my master plan!
Secondly, why not just type the script name in Mike? Well yes, that’s obvious but this has now become my nemesis and would love if someone could crack it for, that way when I replicate this I simply paste it in with no edits.
The script is below for interest (or comment!) and the group in question contains 5 switches (and SCRIPT NAME is where I put the name of the script that’s running).
Thanks in advance guys and gals!
lights_kitchen_on:
alias: Lights - Kitchen - On
icon: hass:led-strip-variant
mode: single
sequence:
- data: {}
entity_id: group.kitchen
service: homeassistant.turn_on
- repeat:
sequence:
- delay: '20'
- data: {}
entity_id: group.kitchen
service: homeassistant.turn_on
while:
- condition: template
value_template: '{{ states|selectattr(''entity_id'',''in'',state_attr(''group.kitchen'',''entity_id''))
| rejectattr(''state'',''eq'',''on'')|list|count > 0 }}'
- condition: template
value_template: '{{ repeat.index <= 15 }}'
- condition: template
value_template: '{{ states|selectattr(''entity_id'',''in'',state_attr(''group.kitchen'',''entity_id''))
| rejectattr(''state'',''eq'',''on'')|list|count > 0 }}'
- data:
message: '{%- set ns = namespace(message = ''**SCRIPT NAME** failed to finish
successfully, devices states are:\n'') -%} {%- for item in states.group.kitchen.attributes.entity_id
-%} {%- set ns.message = ns.message + '' - '' + item + '': '' + states(item)
+ ''\n'' -%} {%- endfor -%} {{ ns.message }}'
service: notify.mobile_app_mike_wood_iphonex
1 post - 1 participant
Read full topic