Ios: Push Token is recreated on each App (re)start

Created on 29 Apr 2019  Â·  28Comments  Â·  Source: home-assistant/iOS

Steps to reproduce:

  1. force quit the App (swipe up etc)
  2. start the App
  3. App creates a new token while homeassistant keeps the old one.
  4. Everytime the App is restarted the App send the token to the server (server receives it and saves it into core.config_entries) but the App recreates a new one.
notifications

All 28 comments

Can confirm this issue still exists in build 44. Robbie: you are doing awesome work here. Please don't think anything less then you being awesome!

I confirm as well. I assume this is why notifications don't work?

Firebase ticket opened, ticket # is 7-1009000026075. They advise response times are currently about 2 business days. Will add some more code to possibly improve the situation in the meantime.

Don't know if it helps, but I reinstalled several builds of the app (all by clearing integrations and reinstalling a clean version of the app). This problem starts in build 42. Builds below that work fine. Builds after 42 would occasionally show a message until you close the app.

In build 46 this problem persists. Note: not all my devices face this problem, only my iPhone X on ios 12.3. The other devices are on 12.2 and have notifications working fine.

42 is right around when we switched to Firebase, so that makes sense.

I can't get build 40 to work anymore. I get a connection error. ObjectMapper failed to serialize response. Build 46 doesn't work either. I see in the notes its says back to ios from mobile_app. Does that mean I need to change my automations to use notify.ios again? If so I should see the device in ios.conf as well? I don't so not sure if I'm thinking about this correctly.

No, do not revert to using the notify.ios entry or ios component. All it meant was the event names have changed back. So if you updated automations from ios. to mobile_app then those should change. There was only a day or two between the first change and the revert being made, so it's unlikely that you even updated your automations.

Of course, as soon as I try to start digging into this issue again I can't reproduce it. Ugh.

@gkron92 try removing the integration via the UI, reset the app (in the app configuration). Remove the app from your phone. Restart HA. Then download build 40, connect, restart HA (sometimes a few restarts are needed). Should work again. (At least it did in my case).

Ok. I tested build 46 again. I deleted the mobile_app integration and the Beta app and started from scratch. The notifications worked. Once i closed the app the push ID changed and the notifications no longer work

@jimz011 Thanks! Your instructions worked and back on build 40 with working actionable notifications

I've tried to recreate this as well and was not able to get the push id to change via app restart. Once it is set up normally it keeps working with the same id.
I did manage to find one odd thing though:
The notify.mobile_app service only gets set up for me when I do not have cloud enabled (signed out) in my HA. Whenever I have it signed in (with or without remote ui enabled) the notify service does not get created.

Firebase got back to me and said basically "everything looks good from here, recheck your integration". @mgiako pointed this out which I think is a good clarification: I understand that the push id changes every time for a firebase bug. I did some tests. Also the push id in core.config_entries keeps changing, and always has the penultimate id of the app. So I think the app sends the push id to HA BEFORE updating it, while it should do it AFTER. I'm right? Makes sense to me and what I figured at least part of the issue was caused by. Will try to figure out whats going on with the update logic.

I reinstalled HA on another (clean) computer. This information might be completely useless to you, but decided to share it anyways. The problem persists with a clean install on Ubuntu 18.04 on a python venv.

From my current setup (not the new one): the core.config_entries is filling up really fast (I removed over 5000 lines already)

Edit: on my fresh install I get this error:

Log Details (ERROR)
Sat May 04 2019 05:51:38 GMT+0200 (CEST)

'iPhone Jimmy'
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/websocket_api/commands.py", line 121, in handle_call_service
    connection.context(msg))
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/core.py", line 1138, in async_call
    self._execute_service(handler, service_call))
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/core.py", line 1160, in _execute_service
    await handler.func(service_call)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/notify/__init__.py", line 112, in async_notify_message
    await notify_service.async_send_message(**kwargs)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/mobile_app/notify.py", line 99, in async_send_message
    entry = self.hass.data[DOMAIN][DATA_CONFIG_ENTRIES][target]
KeyError: 'iPhone Jimmy'

@PierpaoloPernici single handedly saved all y'alls on this one, he deserves 100% of the credit.

I have updated the app, removed the previous integrations and redone the onboarding. However I still receive the “requested entity not found” error.

@jimz011 New build isnt out yet. Within 30-40 minutes or so.

Works here - build 49.

Ah, I thought it was already in the build from a few hours ago :P great news!

@onkelfarmor Same thing I just told @jimz011: New build isnt out yet. Within 30-40 minutes or so.

Great got the new build, notifications are working perfectly again. However now when pulling down to refresh it says:

HA API not configured.

Edit: device tracking seems to be not working.

@robbiet480 i meant it works for me on build 49 (notifications)😁

Confirm same result for me as jimz011

Sent from my iPhone

On May 5, 2019, at 4:26 AM, jimz011 notifications@github.com wrote:

Great got the new build, notifications are working perfectly again. However now when pulling down to refresh it says:

HA API not configured.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

Still having huge troubles with notifications even on the released 2.0 app:
Requested entity was not found. in the HA log and no sign of an attempt in the event log on the iPhone

Still having huge troubles with notifications even on the released 2.0 app:
Requested entity was not found. in the HA log and no sign of an attempt in the event log on the iPhone

Same here. I reinstalled the app and started getting "[homeassistant.components.mobile_app.notify] Requested entity was not found."

Have you confirmed the notify.mobile_app*** service name is correct and as listed in dev tools. If it hasn’t been created you likely need to restart Home Assistant

Hi Tom - I wish it were that simple! Have restarted sooooo many times.

Ok try this:

  • remove integration from Home Assistant (through the integrations UI)
  • remove app from phone
  • restart Home Assistant
  • reinstall app
  • go through onboarding process
  • make sure you select allow on all parts
  • after onboarding pull down to refresh
  • now restart HA, but... make absolutely sure your phone does NOT go into standby!! Keep the app open while restarting. You should see the lost connection bar at the bottom.
  • when HA has restarted go to your developer-tools and then to services.
  • see if the following service is available:
    notify.mobile_app_your_iphone

If this doesn’t work you will need to do a full cleanup which is explained within the HA apps documentation (fortunately for me I never had to do this before and my method has worked for me 100/100, can’t guarantee it will work for you though)

Note that you MUST have websocket active on your HA instance (this only applies if you use something like a proxy manager) and you must have either default_config: or mobile_app: in your configuration.yaml. If you have installed HA not so long ago (say 3 or 4 months ago, you will already have default_config).

Edit: it is better to open a new issue than to react on an issue that has been closed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

riemers picture riemers  Â·  11Comments

wolverinevn picture wolverinevn  Â·  3Comments

fi-sch picture fi-sch  Â·  7Comments

andynbaker picture andynbaker  Â·  3Comments

fi-sch picture fi-sch  Â·  3Comments