New HTML5 notifications fail
Make sure you are running the latest version of Home Assistant before reporting an issue.
You should only file an issue if you found a bug. Feature and enhancement requests should go in the Feature Requests section of our community forum:
Home Assistant release (hass --version):
0.27.0
Python release (python3 --version):
3.4.2
Component/platform: notify.html5/raspi3
Description of problem: Notifications fail to send
Expected: Browser notifications via Chrome (desktop tested)
Problem-relevant configuration.yaml entries and steps to reproduce:
- platform: html5
name: HTML5
gcm_api_key: MASKED
gcm_sender_id: MASKED
- Enable component
- Send notification (used example data from docs)
- Traceback
Traceback (if applicable):
Aug 28 14:06:26 bacchus hass[13463]: INFO:homeassistant.core:Bus:Handling <Event call_service[L]: service_call_id=1978536272-9, service_data=message=Anne has arrived home, data=actions=[{'action': 'open', 'title': 'Open Home Assistant', 'icon': '/static/icons/favicon-192x192.png'}, {'action': 'open_door', 'title': 'Open door'}], domain=notify, service=html5>
Aug 28 14:06:26 bacchus hass[13463]: ERROR:homeassistant.core:BusHandler:Exception doing job
Aug 28 14:06:26 bacchus hass[13463]: Traceback (most recent call last):
Aug 28 14:06:26 bacchus hass[13463]: File "/usr/local/lib/python3.4/dist-packages/homeassistant/core.py", line 852, in job_handler
Aug 28 14:06:26 bacchus hass[13463]: func(*args)
Aug 28 14:06:26 bacchus hass[13463]: File "/usr/local/lib/python3.4/dist-packages/homeassistant/core.py", line 717, in _execute_service
Aug 28 14:06:26 bacchus hass[13463]: service(call)
Aug 28 14:06:26 bacchus hass[13463]: File "/usr/local/lib/python3.4/dist-packages/homeassistant/core.py", line 572, in __call__
Aug 28 14:06:26 bacchus hass[13463]: self.func(call)
Aug 28 14:06:26 bacchus hass[13463]: File "/usr/local/lib/python3.4/dist-packages/homeassistant/components/notify/__init__.py", line 106, in notify_message
Aug 28 14:06:26 bacchus hass[13463]: File "/home/pi/.homeassistant/deps/pywebpush/__init__.py", line 170, in send
Aug 28 14:06:26 bacchus hass[13463]: encoded = self.encode(data)
Aug 28 14:06:26 bacchus hass[13463]: File "/home/pi/.homeassistant/deps/pywebpush/__init__.py", line 146, in encode
Aug 28 14:06:26 bacchus hass[13463]: authSecret=self.auth_key)
Aug 28 14:06:26 bacchus hass[13463]: File "/home/pi/.homeassistant/deps/http_ece/__init__.py", line 141, in encrypt
Aug 28 14:06:26 bacchus hass[13463]: authSecret=authSecret, padSize=padSize)
Aug 28 14:06:26 bacchus hass[13463]: File "/home/pi/.homeassistant/deps/http_ece/__init__.py", line 62, in deriveKey
Aug 28 14:06:26 bacchus hass[13463]: backend=default_backend()
Aug 28 14:06:26 bacchus hass[13463]: File "/home/pi/.homeassistant/deps/cryptography/hazmat/backends/__init__.py", line 35, in default_backend
Aug 28 14:06:26 bacchus hass[13463]: _default_backend = MultiBackend(_available_backends())
Aug 28 14:06:26 bacchus hass[13463]: File "/home/pi/.homeassistant/deps/cryptography/hazmat/backends/multibackend.py", line 33, in __init__
Aug 28 14:06:26 bacchus hass[13463]: "Multibackend cannot be initialized with no backends. If you "
Aug 28 14:06:26 bacchus hass[13463]: ValueError: Multibackend cannot be initialized with no backends. If you are seeing this error when trying to use default_backend() please try uninstalling and reinstalling cryptography.
Additional info:
It's worth noting that extra dev libraries are needed to get the component to install, more info here
I got this when I used the wrong sender ID. It is your "project ID".
I used the 'Project Number' as specified by the linked documentation. I did try the 'Project ID' as well just now but got the same behavior.
I am seeing the same behavior.
16-08-29 17:36:40 homeassistant.core: BusHandler:Exception doing job
Traceback (most recent call last):
File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/core.py", line 852, in job_handler
func(*args)
File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/core.py", line 717, in _execute_service
service(call)
File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/core.py", line 572, in __call__
self.func(call)
File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/notify/__init__.py", line 106, in notify_message
data=data)
File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/notify/html5.py", line 379, in send_message
json.dumps(payload), gcm_key=self._gcm_key, ttl='86400')
File "/home/hass/.homeassistant/deps/pywebpush/__init__.py", line 170, in send
encoded = self.encode(data)
File "/home/hass/.homeassistant/deps/pywebpush/__init__.py", line 146, in encode
authSecret=self.auth_key)
File "/home/hass/.homeassistant/deps/http_ece/__init__.py", line 141, in encrypt
authSecret=authSecret, padSize=padSize)
File "/home/hass/.homeassistant/deps/http_ece/__init__.py", line 62, in deriveKey
backend=default_backend()
File "/home/hass/.homeassistant/deps/cryptography/hazmat/backends/__init__.py", line 35, in default_backend
_default_backend = MultiBackend(_available_backends())
File "/home/hass/.homeassistant/deps/cryptography/hazmat/backends/multibackend.py", line 33, in __init__
"Multibackend cannot be initialized with no backends. If you "
ValueError: Multibackend cannot be initialized with no backends. If you are seeing this error when trying to use default_backend() please try uninstalling and reinstalling cryptography.```
I see this issue as well. Tried re-installing cryptography to no avail.
Can you try installing:
- libffi-dev
- libpython-dev
- libssl-dev
Should be just sudo apt-get install libpython-dev libffi-dev libssl-dev.
It was mentioned in #3046.
@robbiet480
pi@raspberrypi:~ $ sudo apt-get install libffi-dev libssl-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
libffi-dev is already the newest version.
libssl-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 6 not upgraded.
Can y'all please run pip uninstall pywebpush && pip install "https://github.com/web-push-libs/pywebpush/archive/e743dc92558fc62178d255c0018920d74fa778ed.zip#pywebpush==0.5.0". If you run in a virtualenv then activate it first.
I believe that might fix things. It seems like pywebpush isn't being correctly installed
Let me know what you find. If this works for everyone i'll have to figure out what's wrong internally that causes the failed install and push a fix.
Oh before running the command I gave please make sure all 3 of the packages I mentioned are installed (libpython-dev libffi-dev libssl-dev).
Let me summarize:
- Shutdown Home Assistant
- If you use a virtual environment (virtualenv/venv), activate it.
sudo apt-get install libpython-dev libffi-dev libssl-devpip uninstall pywebpushpip install "https://github.com/web-push-libs/pywebpush/archive/e743dc92558fc62178d255c0018920d74fa778ed.zip#pywebpush==0.5.0"- Start up Home Assistant
- Attempt to send a notification over HTML5.
I have the same errors, when trying to send push messages. HASS 0.27.1, windows 10.
@bazis Please try the steps I listed in the comment above yours.
I don't know how to install deb packages in windows ;) I'll try only this pip uninstall pywebpush pip install "https://github.com/web-push-libs/pywebpush/archive/e743dc92558fc62178d255c0018920d74fa778ed.zip#pywebpush==0.5.0"
Somehow pywebpush was not installed, so I run pip3 install pywebpush and notification sucessfully sended without errors, Thanks.
@bazis Ah yeah, for Windows you just need to run the pip commands as per the Installation instructions.
Perfect!
Almost perfect... Try to turn on push notifications from phone with another google account. Get this error homeassistant.components.notify.html5: Saving config file failed: b'Ko_tZNnXXXXXXXXXXXCA==' is not JSON serializable And after that html5_push_registrations.conf became empty. But notifications to first phone still arrives.
I've seen that bug once before but we were never able to track it down. You just need to re-register your device and everything should be fine going forward.
FWIW, I also experienced that serialization issue when toggling push notifications.
Restart HA, register fist phone with my google account, all ok, then second with different - got the same error every time I toggle enable push notification in HASS UI. html5_push_registrations.conf empty again.
UPD: Restart HA, register second phone, then first - no errors.
I'm seeing the same issue with regards to multiple notifications. I think it has to do with HASS restarts messing up the registers/deregisters.