sstratoti / actionable-notifications-subflow-for-ios

Actionable Notifications Node-Red Subflow for Home Assistant Companion - iOS
34 stars 5 forks source link

How to override action title etc? #6

Open aLAN-LDZ opened 1 year ago

aLAN-LDZ commented 1 year ago

Hi

I searched the documentation and unfortunately there is no example of how to replace it. maybe someone will have a moment and help me. Or maybe you know where I can find the exact documentation of the action. My code:

` msg.notificationOverride = {}; msg.notificationOverride.title = msg.push.temat; msg.notificationOverride.subtitle = msg.push.podtemat; msg.notificationOverride.services = msg.push.odbiorca; msg.notificationOverride.message = msg.powiadomienie.calawiadomosc; msg.notificationOverride.interruptionLevel = msg.push.typ;

msg.notificationOverride.action1title = "test1"; return msg; `

sstratoti commented 1 year ago

https://github.com/sstratoti/actionable-notifications-subflow-for-ios/wiki/Override-Values

Your code above looks OK to me, as long as msg.push is being populated before the function node.

If you throw a debug node into the flow and output the full message object, what is the JSON in the debug window? Alternatively, download the latest code and switch "debug mode" to true and it'll output the debug messages we need to troubleshoot.

sstratoti commented 1 year ago

Oh wait! You meant the Action Title for the action itself! Sorry, haven't had my coffee yet.

I don't think I have any overrides for those values. But I think I could work that in. Are there any other values related to the action that you need as well?

sstratoti commented 1 year ago

Please try v0.0.3 and let me know how things go?

For the action[X]Title override functionality, this override will ONLY occur if that action is fully defined in the config. i.e., it must have a default title in the node's config for it to even consider overriding the title.

aLAN-LDZ commented 1 year ago

Sorry for the delay - I haven't had access to my computer for a few days.

Yes, I mean strictly actions and responses to notifications. I understand that if I don't put an override it's like the notification is without action?

I will update and let you know

aLAN-LDZ commented 1 year ago

Unfortunately it does not work :(

function node config before iOS Push:

image

msg.notificationOverride = {}; msg.notificationOverride.title = msg.push.temat; msg.notificationOverride.subtitle = msg.push.podtemat; msg.notificationOverride.services = msg.push.odbiorca; msg.notificationOverride.message = msg.powiadomienie.calawiadomosc; msg.notificationOverride.interruptionLevel = msg.push.typ; msg.notificationOverride.action1title = msg.push.akcja1; return msg;

debug msg after function node:

image

I receive a notification but when I click I don't have access to the "Odkurzaj" action, nothing appears

sstratoti commented 1 year ago

Two things:

First, it's action1Title (note the capital T in Title).

Second, in the iOS notification node, did you set "Debug Mode?" to true? It's from the latest release, it's all the way at the bottom of the config tab for the node. If so, you should see additional debug messages in the debug window without having to setup any debug nodes yourself.

https://github.com/sstratoti/actionable-notifications-subflow-for-ios/wiki/Debugging-and-Troubleshooting

aLAN-LDZ commented 1 year ago

As advised, i changed the name to action1Title and rund debug

but unfortunately it didn't help :(

image

image0

thanks for your time and help!

sstratoti commented 1 year ago

Hmm. Instead of a screenshot, can you copy the debug output and paste that into this issue?

If you hover over the top line of the debug output, a small copy to clipboard icon should appear over to the right hand side.

I need the full JSON to try to figure out what's happening.

Alternatively, expand everything that is collapsed in your screenshot and paste in all the screenshots into this issue.

Thanks!

aLAN-LDZ commented 1 year ago

ok, i wanted to do it before but the copies are terribly scattered:

message1:

{"_msgid":"aac65572bb23897b","payload":1684070014613,"topic":"","powiadomienie":{"typ":"push","calawiadomosc":"Czy włączyć odkurzacz? "},"push":{"typ":"active","odbiorca":"powiadom_wszystkich","temat":"Maniek","podtemat":"","akcja1":"Odkurzaj"},"wiadomosc":{"wiadomosc1":"Czy włączyć odkurzacz?","wiadomosc2":"","wiadomosc3":"","wiadomosc4":"","wiadomosc5":"","wiadomosc6":""},"_event":"node:3b0c384824ba14c4","notificationOverride":{"title":"Maniek","subtitle":"","services":"powiadom_wszystkich","message":"Czy włączyć odkurzacz? ","interruptionLevel":"active","action1Title":"Odkurzaj"}}

message 2:

{"_msgid":"aac65572bb23897b","payload":{"domain":"notify","data":{"title":"Maniek","message":"Czy włączyć odkurzacz? ","data":{"push":{"sound":{"name":"default"},"interruption-level":"active"},"tag":"_JROCD","group":"None"}},"service":"powiadom_wszystkich"},"topic":"","powiadomienie":{"typ":"push","calawiadomosc":"Czy włączyć odkurzacz? "},"push":{"typ":"active","odbiorca":"powiadom_wszystkich","temat":"Maniek","podtemat":"","akcja1":"Odkurzaj"},"wiadomosc":{"wiadomosc1":"Czy włączyć odkurzacz?","wiadomosc2":"","wiadomosc3":"","wiadomosc4":"","wiadomosc5":"","wiadomosc6":""},"_event":"node:3b0c384824ba14c4","notificationOverride":{"title":"Maniek","subtitle":"","services":"powiadom_wszystkich","message":"Czy włączyć odkurzacz? ","interruptionLevel":"active","action1Title":"Odkurzaj"},"_originalPayload":1684070014613}

sstratoti commented 1 year ago

This might help reduce the noise from other debug outputs

image

These options can help to target just the debug output from the current flow in view, or current nodes selected.

So for your config, do you have anything set in action 1 in the iOS node? You have to have something set there as a default in order to override it.

I'm seeing a "title" in your debug, but nothing for the actions. If you press and hold the notification, do any actions show up?

aLAN-LDZ commented 1 year ago

Problem solved :) - I had nothing entered in ios node. When I entered a value there, I could replace it with my own! Cool! Thank you very much

Is it then possible to display one action or two depending on the needs? I'm asking because I have one ios node that handles all notifications and just overwrites the variables

image1

sstratoti commented 1 year ago

Hmmm I'll have to think on this. Would require a more extensive updating of the function node, but I think it's a worthwhile enhancement. Let me get back to you.

aLAN-LDZ commented 1 year ago

You asked earlier if I wanted to change any more values. I tried to replace the image value a moment ago, unfortunately it didn't work, is there such an option?

"msg.notificationOverride.imagePath = msg.push.image;"

sstratoti commented 1 year ago

Not for image, but I could add that to the list.