The “dashboard” names are different in the two servers so what is sent through with “gate”, does not work if received on “winery”. Of course app launching works as the app is local to the phone and not dependent on the notification sender,
Just my thoughts, but it would need to be constructed and not a complete override. I am sure you know this but just pointing out that the token changes.
So therefore, I would see it like
use relative or absolute?
If relative, you already have this code
if absolute, prepend the input_text server URL to it
I would consider this as an edge case since this is an issue due to two remote instances.
So I would assume in either case, internal and external, you’d want to force the url to always point to a single instance of the target server.
Is this the wrong assumption?
Hey @kbrown01 one other question, it should work just fine if the notification script was executed from the gates instance of HA. Is there a limitation to your scenario preventing that option?
Perhaps I do not understand but the execution script is (of course) executed at the gate HA instance. IMHO … The gate instance script builds the notification and it uses relative URLs to do it. That notification is through Android and can be received by that Android phone. BUT … if that phone’s Android Companion App’s current server is not the sending one, no image. As in:
The script runs at the gate HA.
The script attaches “/whatever” to the Android notification as the image source.
The recipient (if their Companion app) is pointed to the gate sees the image.
The recipient (if their Companion app) is pointed to the winery does not see the image.
If the recipient received a notification to “https://blah/blah/blah” it should work (untested but according to the documentation the URL can be absolute).
Which makes total sense to me. The relative URL does not work because it is relative to the current Server in the Companion app. And of course, the relative URL derived from a remote instance is not relevant to the home instance.
That is exactly my test above.
And to answer the other question, I would be happy with a simple “prepend this to to URL” field. But there are other issues that possibly would need to be tested. This is not exactly correct I think:
So I would assume in either case, internal and external, you’d want to force the url to always point to a single instance of the target server.
I want it always to be absolute. Not any old server, but the server in which it is run. Because afterll, that is where the camera is and that is where the token makes sense. It is subtle but could be important and could possibly break things … I can only fork the code and test it and try I guess.
Edge? Perhaps. But we live on a two HA instance scenario. I could always write it sans blueprint which I guess I will need to do unless this is considered valuable.
Okay so according to your reply, my understanding is correct, maybe just confusion due to the terms used. No problem, I could churn out a simple input to prepend the URL.
Do allow me some time, Sunday is a no work day for me.
No issues. It is the only thing that I do not get from this and the image would be killer.
Not knowing the entire implementation, it is likely not possible that it could be a simple boolean (use absolute or relative) …
It could be some Nabu Casa address.
It could be some other DuckDNS address.
It could be some local address
… I do not think you could actually guess at what it should be … so you are 100% correct it comes down to “prepend this”
No worries, I’ve tried to write a custom one where i can customize the message, title action etc in automations but I’m getting stuck when it comes to successfully referencing the fields for some field types.
Text and notification icons appear to work with “{{insertfieldvariablekeynamehere}}” in the sequence however booleans, rgb colour, and select types don’t.
Can anyone with more knowledge than me take a read over and let me know where I’m going wrong. I can’t find documentation on this.
service: notify.mobile_app_samsung_galaxy
data:
message: "{{message}}"
title: "{{title}}"
data:
notification_icon: "{{notification_icon}}"
color: "{{colour}}"
persistent: "{{persistent}}"
tag: "{{tag}}"
channel: "{{channel}}"
importance: "{{importance}}"
alias: Send a notification to Richard's Samsung Galaxy
For colour, you can copy the snippet in my blueprint. The shape of the data being passed in the template matters.
I have a 1 liner designed for converting the RGB selector to the data shape required by the colour parameter.
Yeah I was trying to follow it to replicate, is it this part or the whole thing “{% endif %}\n {%
if enable_icon_color %}{% set p.d = dict(p.d, **{ ‘color’: icon_color_hex })”
That’s a part. I like to create a namespace because we can modify variables easily in a namespace.
The part you’ve copied is modifying the namespace p
.
So you’d have to create the namespace before this part, and then return p.d
as the result to be stored in the variable.
Edit: Actually, rather than this, you’d need the template used in icon_color_hex.
So something like
variable:
icon_color_hex: ‘{{ “#{:02x}{:02x}{:02x}”.format(icon_color_selector[0], icon_color_selector[1], icon_color_selector[2]) }}’
then in the notification
color: !input !icon_color_hex?
Just FYI, I have tested this in a simple script and I can confirm it works as expected (sensitive data x’d out but you get it). Prepending the address sends the image no matter what server my Companion app is pointed to). Simple automation added where the camera_location is passed in from one of the cameras (“gate”, “intercom”, “driveway”, …) as the trigger.id
to send a notification with image from the proper camera. Now just adding multiple phones and all is wonderful although I would like it to be in the blueprint as I would use it for other things.
alias: Test Send Image
variables:
server: https://xxxxxxxxxxxxxxxxxxx.ui.nabu.casa
camera_location: gate
camera_entity: camera.rc_{{camera_location}}_fluent
image: "{{state_attr(camera_entity,'entity_picture')}}"
camera_name: "{{state_attr(camera_entity,'friendly_name')}}"
phone: kevin_phone
sequence:
- service: notify.mobile_app_{{phone}}
data:
message: Current Status of {{camera_name}}
data:
image: "{{server}}{{image}}"
mode: single
Yup, remember to assign your selector value to a variable before hand.
In the notification it’ll just be color: "{{ icon_color_hex }}"
Hey @kbrown01, I’ve updated the Beta 2 to include the server url prepending option, you can import it easily here.
Please note, this is the single device variant.
Sweet and how do you do booleans and the select type as well. Just doing {{ field id name here }} didn’t seem to work for me for that.
If you don’t have to transform the data, it should just be !input blabla
Sweet and just clarifying that’s in variables too or the notify action itself?
Sadly I’m not having any luck with the color, I’m getting “Failed to call service script.system_send_notifications_to_all_devices. ValueError: Unknown format code ‘x’ for object of type ‘str’” errors with these values
icon_color:
selector:
color_rgb: {}
name: Icon Color
description: The colour of the notification icon
required: true
default:
- 102
- 186
- 240
- variables:
icon_color_selector: "!input icon_color"
icon_color_hex: >-
{{ "#{:02x}{:02x}{:02x}".format(icon_color_selector[0],
icon_color_selector[1], icon_color_selector[2]) }}
- service: notify.mobile_app_samsung_galaxy
data:
message: "{{message}}"
title: "{{title}}"
data:
notification_icon: "{{notification_icon}}"
color: "{{icon_color_hex}}"
persistent: "{{ persistent_notification }}"
alias: Send a notification to Richard's Samsung Galaxy
alias: Standard Notification
Since we’re digressing significantly from the core topic of this post, if you want to, we can continue in a private message. I don’t mind chipping in a couple more exchanges and links to documentation
Sounds good, your profile is showing as hidden so it doesn’t let me send ya a message at the moment
Tested and gets my big thumbs up! Works as expected, thank you for this.
Now I can move this script to the winery Home Assistant, grabbing the screen from the Gate camera.
This is the perfect solution so that I can then trigger many things in the Winery system.
I can do this using Remote Home Assistant so it basically just sends the sensor change (vehicle motion detected) to the winery Home Assistant and then everything else is local to the winery.
This is exactly what I wanted for this part. Only need to test if the state update is an acceptable timeframe (HA Gate → (Nabu Gate → Nabu Winery through Remote Home Assistant) → HA WInery → Automation for State change → many things happen, including the notifications …
Plus I like that you did this as a script that can have variables, so I have already implemented which camera:
alias: Rio Crest Gate Camera Alerts
description: Handles all alerts coming from vehicles detected at the Rio Crest gate system
trigger:
- platform: state
entity_id:
- binary_sensor.rc_intercom_vehicle
to: "on"
id: intercom
- platform: state
entity_id:
- binary_sensor.rc_gate_vehicle
to: "on"
id: gate
- platform: state
entity_id:
- binary_sensor.rc_driveway_vehicle
to: "on"
id: driveway
- platform: state
entity_id:
- binary_sensor.rc_backentrance_vehicle
to: "on"
id: backentrance
- platform: state
entity_id:
- binary_sensor.rc_arrivalarea_vehicle
to: "on"
id: arrivalarea
condition: []
action:
- parallel:
- service: script.send_motion_notification
metadata: {}
data:
field_notify_device: 9f8ff81591a0936eb19abc1b944fd120
field_title: Alert for {{camera_location}}
field_message: A vehicle was detected at the Rio Crest {{camera_location}}
field_subtitle: ""
field_attachment_type: camera_entity
field_attachment_camera_entity: camera.rc_{{camera_location}}_fluent
field_attachment_server_url: https://evb1rlupv05th17yava798chienv34sh.ui.nabu.casa
field_timeout:
hours: 0
minutes: 1
seconds: 0
field_notification_link: app://com.mcu.reolink
- service: script.send_motion_notification
metadata: {}
data:
field_notify_device: 4f39f9ccf30de534a64fd9c67ddd706a
field_title: Alert for {{camera_location}}
field_message: A vehicle was detected at the Rio Crest {{camera_location}}
field_subtitle: ""
field_attachment_type: camera_entity
field_attachment_camera_entity: camera.rc_{{camera_location}}_fluent
field_attachment_server_url: https://xxxxxxxxxxxx.ui.nabu.casa
field_timeout:
hours: 0
minutes: 1
seconds: 0
field_notification_link: app://com.mcu.reolink
variables:
camera_location: "{{trigger.id}}"
mode: single
I will clean all this up and likely pass the whole camera (and server URL because it will have other Nabu URLs in the future for other entrances) in variables.
For now I put in a parallel action to test two different “notify_devices” but I assume your comment “this is a single device variant” means you have multi-device support but just not in this beta version.