CCOSTAN / Home-AssistantConfig

:house: Home Assistant configuration & Documentation for my Smart House. Write-ups, videos, part lists, and links throughout. Be sure to :star: it. Updated FREQUENTLY!
https://www.vCloudInfo.com
Other
4.78k stars 509 forks source link

Replaceable IOS notifications #750

Closed CCOSTAN closed 4 years ago

CCOSTAN commented 4 years ago

Add in the ability to replace notifications.

https://companion.home-assistant.io/docs/notifications/notifications-basic#replacing-notifications

Specifically for my Medicine alert.

CCOSTAN commented 4 years ago

anyone have this working?

jcallaghan commented 4 years ago

Yes, let me post up my example tomorrow. I've been using it with my BBQ to keep replacing the internal temperature of the food I'm cooking with my Meater+ jcallaghan/home-assistant-config#50.

CCOSTAN commented 4 years ago

Yes, let me post up my example tomorrow. I've been using it with my BBQ to keep replacing the internal temperature of the food I'm cooking with my Meater+ jcallaghan/home-assistant-config#50.

Do the iOS notifications replace each other when a new one comes in?

CCOSTAN commented 4 years ago

Running this easy test shows that it is not working. :( They keep creating new popups on the phone. image CAn someone else test this?

title: "Test"
message: "This is a Test Message that should only appear once since it replaces the last one."
data:
  apns_headers:
    'apns-collapse-id': "Test_Message"
pinkywafer commented 4 years ago

Haven't got iPhones to test, and shouldn't make a difference, but the docs show the apns-collapse-id in single quotes, ie: 'apns-collapse-id': 'test_message'

pinkywafer commented 4 years ago

I've also seen many issues around the apns-collapse-id in many different projects, so could be any number of causes! I'd be inclined to try lower case only and no special characters also, in case certain characters are not supported.

CCOSTAN commented 4 years ago

Good Suggestions @pinkywafer . I tried them but still no dice.

title: "Test"
message: "This is 1 Test Message that should only appear once since it replaces the last one."
data:
  apns_headers:
    'apns-collapse-id': 'test'

image

jcallaghan commented 4 years ago

Same behaviour for me. Since posting my previous that where I thought I had this working I've actually observed it isn't working. I need to check on my iPad as I think this is where I saw it working.

Just testing with @CCOSTAN now the original message duplicates for me and then it is followed by the new message but only with the second message. The third message is delivered without any duplication but the old thread/message is not replaced.

  1. 1X message sent with apns-collapse-id > 1X message received.
  2. 2X message sent with apns-collapse-id > 1X message received and 2X message. 1X still exists.
  3. 3X message sent with apns-collapse-id > 1X,2X still exist and 3x received.

example.zip

CCOSTAN commented 4 years ago

Was using the old notify.ios* service rather than the new notify.mobile_app_* service. Switching everything to that made everything work as expected.

https://companion.home-assistant.io/docs/getting_started/migration/

Migrating to Home Assistant Companion 2019.1 | Home Assistant Companion Docs
!iOS
jcallaghan commented 4 years ago

Great summary Carlos. This explains why my BBQ temperatures were working on my iPad whereas I too am still using the ios* service for my iPhone. Normally just copy and pasting from a previous automation. Time for some notify service find and replace me thinks. Great collab!

CCOSTAN commented 4 years ago

@jcallaghan Thanks for the additional testing. @TomBrien was the superstar who pointed me towards the solution though. :)

Be sure to clean out the old stuff @jcallaghan. I had a few things leftover that the migration guide pointed out for cleaning.