Home Assistant Community

Need help with iOS notifications

ios
notification
Tags: #<Tag:0x00007f3761d4d8d0> #<Tag:0x00007f3761d4d740>
#1

Hello, I am trying to get iOS notifications working for myself and I am hitting a brick wall.

I am running Hass.io 0.74.2 in docker on Linux Mint 18.3 Xfce 64-bit.
I installed SSL certs via Certbot in command line and my certificates are signed by Lets Encrypt
Every time I reload HA I do update push settings on the iPhone.

I think I have tried just about every different way of configuring the notifications in my config files.
I also tried sending a manual notification via the services tab.
I am using code that a friend sent me that he says is working for him and its still not working for me.
I have also tried sending a manual notification in the services tab.
{"message", "Testing one, two, three"}

Sorry if this is alot of info I’m about to dump on here. I am trying to give any relevant info I can think of. I appreciate any help anyone could offer.

edit: I discovered there is an issue with Docker and resolving DNS so I fixed that. Now I am successfully resolving DNS from within the container but I am still getting errors. I added a fresh copy of my log.

here is my configuration.yaml ios section.

ios:
  push:
    categories:
      - name: light1
        identifier: 'LIGHT1'
        actions:
          - identifier: 'LIGHT_OFF1'
            title: 'Turn off Light'
            activationMode: 'background'
            authenticationRequired: yes
            destructive: yes
            behavior: 'default'

Here is my automation

  - alias: 'Notify Light On'
    trigger:
      - platform: state
        entity_id: light.bedside_light
        from: 'off'
        to: 'on'
    action:
      service: notify.ios_chris_iphone
      data:
        title: "Reading Light"
        message: "Reading Light is On"
        data:
          push:
            badge: 0
            category: 'LIGHT1'  
 
  - alias: 'Push Action Light Off'
    trigger:
      platform: event
      event_type: ios.notification_action_fired
      event_data: 
        actionName: LIGHT_OFF1
    action:
      service: light.turn_on
      entity_id: light.bedroom_ceiling_light

Here is a copy of my log from the moment I first see mention of notify.

During handling of the above exception, another exception occurred:

2018-08-27 18:48:50 ERROR (MainThread) [homeassistant.core] Error executing service <ServiceCall notify.ios_chris_iphone: title=<homeassistant.helpers.template.Template object at 0x7f20a68e07b8>, message=<homeassistant.helpers.template.Template object at 0x7f20a68e0a58>, data=push=badge=0, category=LIGHT1>
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 171, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw)
  File "/usr/local/lib/python3.6/site-packages/urllib3/util/connection.py", line 56, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/usr/local/lib/python3.6/socket.py", line 745, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Try again

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 343, in _make_request
    self._validate_conn(conn)
  File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 849, in _validate_conn
    conn.connect()
  File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 314, in connect
    conn = self._new_conn()
  File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 180, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x7f20a68fcf98>: Failed to establish a new connection: [Errno -3] Try again

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 445, in send
    timeout=timeout
  File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/lib/python3.6/site-packages/urllib3/util/retry.py", line 398, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='ios-push.home-assistant.io', port=443): Max retries exceeded with url: /push (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f20a68fcf98>: Failed to establish a new connection: [Errno -3] Try again',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/core.py", line 1038, in _event_to_service_call
    await service_handler.func(service_call)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/notify/__init__.py", line 137, in async_notify_message
    yield from notify_service.async_send_message(**kwargs)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/notify/ios.py", line 94, in send_message
    req = requests.post(PUSH_URL, json=data, timeout=10)
  File "/usr/local/lib/python3.6/site-packages/requests/api.py", line 112, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/api.py", line 58, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 512, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 622, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 513, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='ios-push.home-assistant.io', port=443): Max retries exceeded with url: /push (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f20a68fcf98>: Failed to establish a new connection: [Errno -3] Try again',))
0 Likes

#2

You need to make sure that you are pointing to the correct certificate location in your configuration.yaml file.

I would think it would work as long as HASS can see the location, but I don’t have that much experience with docker or hassio.

0 Likes

#3

I couldn’t get hassio to see the certificates in their default location so I created hard links to the ssl folder in the hassio folder. I did sudo ln etc/letsencrypt/archive/fullchain1.pem usr/share/hassio/ssl/fullchain.pem and again for the privkey.pem. My SSL functions work fine otherwise. I am able to remotely access my HA page using my https:// prefixed link. I am also using my Asus routers built in DDNS function for my domain name.

0 Likes

#4

hey i saw your post on facebook
first… i don’t know anything about the docker thing but if you are able to connect to your HA from outside the notifications should work
second… are you able to get regular ios notifications? and only the actionable notifications are not working?
if you are not getting any try the services tab select notify.ios_chris_iphone the on the json use this
{ “message”:“Did you get this message?”, “title”:“this is a test”}
if you get the message try to use use this configuration

ios:
  push:
    categories:
      - name: light1
        identifier: 'light1'    # this must be lower case and must match the category on the automation part
        actions:
          - identifier: 'LIGHT_OFF1'
            title: 'Turn off Light'
            activationMode: 'background'
            authenticationRequired: yes
            destructive: yes
            behavior: 'default'

automation part

  - alias: 'Notify Light On'
    trigger:
      - platform: state
        entity_id: light.bedside_light
        from: 'off'
        to: 'on'
    action:
      service: notify.ios_chris_iphone
      data:
        message: "Reading Light is On"
        data:
          push:
            badge: 0
            category: 'light1'  #this must match the identifier  part and must be lower case  
 
  - alias: 'Push Action Light Off'
    trigger:
      platform: event
      event_type: ios.notification_action_fired
      event_data: 
        actionName: LIGHT_OFF1
    action:
      service: light.turn_on
      entity_id: light.bedroom_ceiling_light

restart HA and don’t forget to update the push notificatio in the IOS app
if this don’t work let me know i try to help as much as i can

0 Likes

#5

Hey Kem,

No, I can not get notifications to work at all. I have tried the test method already. Using the exact same format.

As for the lowercase thing. Yeah, I read that on the site. My original config had them in lowercase. Someone else that has tried to help me along the way said he has his in caps and it still works. what you see in my post is what he sent me. but at any rate, if basic notifications from the services tab arent working then there is probably something else going on.

I appreciate any help you can offer. Thank you!

0 Likes

#6

So I attempted to install Pushbullet last night and the component is failing to load at startup. I read something last night that seems to indicate that if the component tries to load before the docker container has full connected to the network that it will error out and does not attempt to load again. So I need to figure out how to delay a few component or perhaps the Home Assistant program itself until after the container has full network connectivity. Hopefully if I solve the Pushbullet problem it will also fix the iOS problem.

I have been googling my heart out. Man I wish I could find someone to help lol. I’m finding some interesting tidbits but not enough for me to understand what the heck I need to do. Lol

0 Likes

#7

Hey did you ever have any luck finding out this issue? My ios notifications aren’t working either on the newest home assistant app. I’ve got the checkboxes ticked, and added ios to the config and I’m trying to send myself a test message and nothing is getting through.

0 Likes

#8

Checkboxs? Did you turn on your automation’s that send the messages?

0 Likes

#9

yeah on the home assistant ios app you’ll see checkboxes or x’s depending on whether the device has been synced properly or not. In my case it was an issue with the device id, and once I updated that I was good to go.

0 Likes

#10

Reboot your pi and turn off your iPhone then turn it back on that solved my problem

1 Like

#11

My device ID was off, but I looked in the logs and it gave me the proper one, popped it in, and BOOM! OFF TO THE RACES BABY!

0 Likes

#12

Hey!

So what it seemed to end up being was that the ios component was trying to load before HA’s docker container had connected to my home network. From what I could find out if a component failed to load it would never try to load again until next restart. For the life of me i couldn’t figure out how to go into the docker container and configure HA to wait to start until after the container had joined. What ended up solving my problem was that I reinstalled HA into a Python venv. However I lost the Hassio addons tab so a few months later I tried Docker again and this time I did not have any issues.

0 Likes