Moving forward, updates to this subflow will be found at the following repository: https://github.com/sstratoti/actionable-notifications-subflow-for-ios
-
-
Save sstratoti/8021c5a4ee8e34313c3f59ba20c4a83a to your computer and use it in GitHub Desktop.
Feel silly asking this question, but I have read through this thread a few times now, I keep getting a 'no connection' error message on the node. Was expecting at least getting a notification as I was getting using the android version of the same subflow. I figure I'm doing something wrong with the config, I have tried both using both notify and mobile_app_eddie as the notify service, neither worked. Can anyone please assist?
I figured out the issue. For the call-service nodes in the subflow, I have multiple instances of the Home Assistant server listed, changing that around and found one that allowed the connection.
@pistak23 - thanks for catching that. The default value is set to "default" which is obviously > 0, so the custom sound would never hit in the logic. Swapping those variables will have it check the custom first, then the default sounds - so that looks good to me. I'm making a correction and will edit the gist to update it.
@fireone23 glad to hear its working now! I've run into that issue myself before, it's frustrating til you figure it out. :)
I believe that you can edit the servers that are available, and remove the dead ones from the list. I think thats what I did long ago...
Since 2021.10 iOS actionable notifications allow icons to be included. Mac owners can find the list of SF symbols here. For Windows user, one could look at this list (the list will only show the names, and may not be complete).
Please note that while this works fine on the iPhone, the current versions of WatchOS (even v8.3) will not show such icons.
Following changes should be made to the code:
'create service call' (--> indicates line added)
const destructive = env.get(`${name}Destructive`);
const behavior = env.get(`${name}Behavior`);
--> const icon = env.get(`${name}Icon`);
const actionObject = {};
actionObject.action = action;
if (destructive != "") actionObject.destructive = destructive;
if (behavior != "") actionObject.behavior = behavior;
--> if (icon != "") actionObject.icon = icon;
actions.push(actionObject);
}
Following should be added (in the actionable-notifications-subflow-for-ios.json) after each of the action_TextInputPlaceHolder (where _ is the number 1-4):
{ "name": "action1Icon", "type": "str", "value": "", "ui": { "label": { "en-US": "Action 1 Icon (Optional)" }, "type": "input", "opts": { "types": [ "str", "env" ] } } },
Just remember to change "action1Icon" and "Action 1 Icon (Optional)" accordingly ;)
Is it possible to set notifications properties from the msg.payload ? (such as the message title or message text)
This subflow is great. I had originally posted a question about a problem I was having, but worked it out. Thanks for putting this together.
@fslef - Yes, this is possible. What I do is place a function node in between whatever node is pushing the payload (say an events:state node, or trigger:state).
For instance, here is a flow that I use for my litter robot.
...the status code switch is checking the various codes to see if they match any of the ones that I care about.
The "Set Message" function node is what we're interested in.
// set msg overrides
msg.notificationOverride = {};
msg.notificationOverride.title = "Litter Robot error message!";
msg.notificationOverride.message = "Litter Robot is reporting '" + msg.data.attributes.status + "' (" + msg.data.attributes.status_code + "). Please check the litter robot.";
return msg;
You can override the default properties that you've set for the service call by passing in a msg object with notificationOverride set.
// set msg overrides
msg.notificationOverride = {};
msg.notificationOverride.title = "dynamic title!";
msg.notificationOverride.subtitle = "dynamic subtitle";
msg.notificationOverride.message = "Some new message like Battery is at " + msg.payload.attributes.battery + "%";
msg.notificationOverride.services = "my_phone, partners_phone, kids_phone"; //could override this depending on who is "home".
msg.notificationOverride.tag = "xyzTag" // could be that you want to send the same message, but have it appear multiple times on the device rather than overwritten.
msg.notificationOverride.clear = true; // will attempt to clear all messages to all specified devices in the setup or in msg.notificationOverride.services if overridden. I believe this currently isn't working because apple isn't allowing them to do this with the app. But they've petitioned for it...
return msg;
All of these are optional. If you send in a value, it'll override the default values set in the node so that its more dynamic.
Also, I use the "msg.notificationOverride.services" to dynamically set who gets a message based on who is home, the time of day, if we're asleep, etc. I do this all using another subflow called "Who to send messages to?". It helps to keep things really clean and doesn't bother my wife while she's at work (for instance).
Glad you figured it out @DeltaNu1142 !
Also, thank you @henriklund - gist is updated!
Thanks @sstratoti
Ok I see. So everything should go through the msg.notificationOverride
Would you mind if you share your flow ?
So that I can have a look on the other nodes ?
Thanks a lot
@sstratoti, do you plan to publish this as a subflow module?
Hi @fslef - I’ll see what I can do next week.
@bonanitech - had no idea about this! Very cool, and this would be much easier for people to receive updates to the node! I’ll also look into this next week as well.
Awesome! It may also be a good idea to scrub the flow with this tool before that. 😉
@bonanitech Just did a diff after using that tool, had no idea that the server ID was in there, but it makes sense that it would be. The HA nodes need to use something to connect...
Is there a way to set that dynamically with the subflow module? Or all you all just going in and changing the HA nodes to point at your own instances each time I update this?
EDIT: Or using the scrubber you linked to replace the id... hah
And next week turned into next year...
Sorry, work/life has been kicking my ass. I'm planning some time off over the next month or two, so I'll see about publishing it then. :)
It looks like there is a problem with nodes that depend on configuration nodes in subflow modules. We'll have to wait for a fix first.
You mean for the subflow module? Also, you reminded me. I updated the code with a bug fix. I'll push that up now.
Allows you to pass in an msg.notificationOverride.url into the subflow.
I use this to send me an alert when a new version of HA is available, and dynamically send in the URL to the blog post. :)
I'm also doing the same for HACS updates, and I send the user to the /hacs page in the app so I can easily (and heedlessly) keep things on the bleeding edge.
You mean for the subflow module?
Yes, I built a subflow module last week, and I noticed the issue during my testings. After installing it on a different machine, it didn’t work as expected because the reference to the configuration node was not valid anymore. Unfortunately, there's currently no way to manage the link between nodes inside a subflow module and configuration nodes.
I reported this issue via Slack a few days ago, and there is a post about the same issue on the forum (link below).
https://discourse.nodered.org/t/packaging-a-subflow-as-a-module-missing-broker-configuration/55485
Out of curiosity, is there a reason why this subflow is limited to four actions?
Last time I checked the docs, an iOS notification was limited to 4 and Android was limited to 3. Has there been a change that I missed?
Ah - interesting. Android is limited to 3, iOS says the following:
“ iOS allows around 10 actions. Any more and the system UI for actions begins having scrolling issues”
Aside from the flow’s form being monstrous? Hahaha
Thought so. I tweaked the code to 8 actions and that worked like a charm, so just wondered... (I had one for volume +5, +1, -1, -5 and wanted add toggle for mute).
Do you want a copy of the modifications?
Hello @sstratoti,
I really liked your subflow and used it to replace some existing flows.
When using your sub-flow, I had few options missing that I used in my existing flows, so I tweaked your flow a bit to support them.
I would like to share the modified flow with you so you can review the changes and incorporate them in your flow for others to use if you would like.
- First change I made, adding "No-sound" to the sounds list and changed "create service call" to send a silent message in such a case.
- I changed "isCritical" Boolean to a list with interruption levels support, now you can choose between [Critical/Time Sensitive/Passive/Normal] instead of the old way that only supported [Normal/critical], and again changed "create service call" node to support this.
You can find my sub-flow json in my fork:
https://gist.github.com/okets/c7baea968aab019a09c9d2c80df29d40
I only changed the [input] node and the [create service call] node, so it should be easy enough to merge the changes.
I also changed the "info" link in the documentation to direct to this discussion instead of the broken link that was there.
Thank you for sharing,
let me know if you find my changes helpful.
This is great, thanks so much for this! I'm in training this week and next, so I don't think I'll be able to take a look right away at merging it in, but I'll put it on my todo list!
I wanted to ask everyone's opinion about something. I've included a LOT of configuration options in this subflow. I've tried to incorporate all of the options that were available at the time, but I feel like I'm not using most of them. What do people feel about a "lite" version of the subflow and a "max" version?
I wish I could expand/collapse menu options depending on selections, or even group menu options together - but I don't think this is possible in a subflow, is it?
My $0.02 (which thanks to current events is worth less than $0.01) is, even if I don't use all of the config options, I still want to see them. It gives me ideas about how to use it that I probably wouldn't have otherwise.
I think your question will be better answered by someone that doesn't want to see unused config options, though... if that person exists!
@sstratoti
You documented the sub-flow's inputs very well and most of the inputs are optional.
in fact, It works so well that I am using your sub-flow for sending non-actionable messages as well.
In my opinion a lite version is not necessary.
BTW,
I also implemented an option to get the phone that triggered the Action so I can reply back only to it instead to all devices.
I use it for sending confirmation messages back to whoever triggered the action and not to all users.
I do it by populating the "services" to the following:
var triggeringPhoneName = msg.eventData.event.sourceDeviceName.replace("-","_").replace(" ","_").replace("’","").toLowerCase(); msg.notificationOverride={'services': 'mobile_app_'+triggeringPhoneName};
Works like a charm!
Thought so. I tweaked the code to 8 actions and that worked like a charm, so just wondered... (I had one for volume +5, +1, -1, -5 and wanted add toggle for mute). Do you want a copy of the modifications?
Do you have a copy somewhere where I could grab it and review it? I think I've made a few more updates and I want to make sure I don't lose them. I think I may turn this into a github project so we can use pull requests and an issue tracker...
Love this subflow - works amazingly well. Trying to review the documentation to make some tweaks on my setup but I'm getting a 404? Is there an alternate source?
Link I'm getting from subflow: https://zachowj.github.io/node-red-contrib-home-assistant-websocket/cookbook/actionable-notifications-subflow-for-ios.html
Yeah, I was planning on submitting it to the HA NodeRed cookbook but was beta testing it a bit first - so thats a dead link right now. One day!
This is the link to the documentation I'd originally set up:
https://gist.github.com/sstratoti/8021c5a4ee8e34313c3f59ba20c4a83a?permalink_comment_id=3741675#gistcomment-3741675
Check out this post to see what the options are for message overrides:
https://gist.github.com/sstratoti/8021c5a4ee8e34313c3f59ba20c4a83a?permalink_comment_id=3966887#gistcomment-3966887
Let me know if you have any questions about this - the documentation might be slightly out of date, but I'm here to help and answer questions. :)
Hello again,
I tried to repair this mistake, and I think I done it. In subflow in node function "create service call" I replaced "customSoundPreInstalled" and "customSound" and now it works. Please check it and if is correct, update this node for other people. Thank You