openhab / openhab-cloud

Cloud companion for openHAB instances
Eclipse Public License 2.0
315 stars 161 forks source link

[WIP] FCM enhancements #462

Closed digitaldan closed 4 months ago

digitaldan commented 4 months ago

Edited with updated JSON

This will support allowing openHAB to send much more complex data types to FCM. This also helps support actions, specifically with IOS and dynamically creating actionable categories.

see https://github.com/openhab/openhab-android/issues/3193

sample push payload from openHAB might look like

{
  "media-attachment-url": "https://upload.wikimedia.org/wikipedia/commons/thumb/0/07/OpenHAB_logo_2.svg/541px-OpenHAB_logo_2.svg.png",
  "message": "Someone is at the Gate 2",
  "on-click": "navigate:mainui:popup:widget:gate_control",
  "actions": [
    {
      "title": "Turn Office ON",
      "action": "command:F1_DansOffice_Light:ON"
    },
    {
      "title": "Turn Office OFF",
      "action": "command:F1_DansOffice_Light:OFF"
    },
    {
      "title": "Go To Office",
      "action": "ui:navigate:/page/roomDanOffice"
    }
  ]
}
mueller-ma commented 4 months ago

Maybe on-click instead of navigate as using pops here doesn't sound as "navigation" to me.

digitaldan commented 4 months ago

@mueller-ma how about click-action ?

digitaldan commented 4 months ago

Actually i guess on-click makes it more clear when describing in the cloud binding for rules. So i'll go with that for now.

My original thought was that the only action that makes sense when clicking on the notification is a navigate command. So i was not planning on supporting a command action. Playing devils advocate, i guess supporting the same "action" we have in action buttons here would give the user more power, and might be easier to explain, and i guess i could see sending a command to an item when clicking to do something like an acknowledgment ~instead of bringing the app to the foreground~.

@mueller-ma let me know if you have an opinion.

digitaldan commented 4 months ago

After sleeping on it, i kinda like making the "action" format consistent, and that format can be used both in the on-click, and in the dynamic actions buttons.