I took a look at Google's new API and found a way to restore phone notifications using Custom HTTP/Action notifications. So this will work as long as you're not already using that feature. There are a couple other caveats. You'll need an SQLite database viewer. Also if you use Android and iPhones together you either need to only use Android notifications, or there will be some limitations with the android notifications. Which I'll touch on later.
My goal was to create a Custom HTTP/Action that would mimic the one that's generated by Domoticz but connects to the new API used by Google. To that end I looked in the newest beta version of Domoticz's source code on Github to figure out how it currently interfaces with Google. I then created an Custom HTTP/Action to mimic that request.
The first thing you need to do is open up the Notification settings in your Domoticz instance. Scroll down to the Custom HTTP/Action box. Then you need to get your phone's unique registration ID for the domoticz app. You're not able to find this information anywhere inside Domoticz because if someone gets the ID they can spam your phone with notifications. You can only find this inside the database. The database is in the Domoticz folder and it's called domoticz.db.
You'll need to open the database file using an SQLite viewer and view the MobileDevices table. In the MobileDevices table the field that contains your phone's unique ID is the SenderID. You DON'T need the UUID field. Now for every phone you want to receive notifications copy the SenderID for that phone from the database into the TO field in the Custom HTTP/Action box in Domoticz. You'll need to surround every ID with double quotes (") and separate them with a comma followed by a space (, ). It should look like this:
Code: Select all
"PhoneID-1", "PhoneID-2", "PhoneID-3"
The next thing you'll need is to copy and paste the following URL into the URL/Action field: https://fcm.googleapis.com/fcm/send That is the new URL for Google's notification API.
For people WITH iPhones you need to copy and paste the following JSON packet into the POST Data field. This is what tells the Google API the contents of the notification. Note: If you want to use both Android and iPhones together you need to use this code. The issue is the Domoticz notifications on Android will only be able to use the default notification sound.
Code: Select all
{"registration_ids": [#TO], "notification" : {"subject": "#SUBJECT", "body": "#MESSAGE", "sound": "#FIELD1", "extradata": " ", "priority": "#PRIORITY", "deviceid": "0", "message": "#SUBJECT", "content_available": true } }
Code: Select all
{"registration_ids": [#TO], "data" : {"subject": "#SUBJECT", "body": "#MESSAGE", "extradata": " ", "priority": "#PRIORITY", "deviceid": "0", "message": "#SUBJECT", "content_available": true } }
Lastly you'll need to copy and paste Authorization: key=AIzaSyBnRMroiDaXCKbwPeOmoxkNiQfjWkGMre8 into the POST Headers field. This is Domoticz's unique app key and it tells Google it's a Domoticz notification.
Now save your settings and then click the test button in the Custom HTTP/Action box. If you did everything correctly and all goes well you should receive a notification on your phone from Domoticz.
Finally you'll need to go and check that HTTP notifications are turned on for all you're devices. I recommend leaving the GCM notifications on for all your devices, but just disable GCM from the notifications tab in the settings. That way when you can finally upgrade Domoticz to a later version all you have to do is enable GCM and disable the HTTP notifications in the settings screen. If you forget to disable HTTP notifications then you'll receive two notifications at once instead of one.