Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Apple Push Notification Service #3756

Merged
merged 35 commits into from
Oct 18, 2016
Merged

Conversation

sam-io
Copy link
Contributor

@sam-io sam-io commented Oct 8, 2016

The APNS platform uses the Apple Push Notification service (APNS) to deliver notifications from Home Assistant.

To use the APNS service you will need an apple developer account and you will need to create an App to receive push notifications. For more information see the apple developer documentation.

Pull request in home-assistant.io with documentation (if applicable): home-assistant/home-assistant.io#905

Example entry for configuration.yaml (if applicable):

notify:
  platform: apns
  name: doorbell_app
  sandbox: true
  cert_file: doorbell_app.pem

Configuration Variables:

name: The name of the app.
sandbox: If true notifications will be sent to the sandbox (test) notification service.
cert_file: The certificate to use to authenticate with the APNS service.

Usage:

The APNS platform will register two services, notify/[app_name] and apns/[app_name].

apns/app_name:

This service will register device id's with home assistant. In order to receive a notification a device must be registered. The app on the device can use this service to send its id during startup, the id will be stored in the [app_name]_apns.yaml.

See didRegisterForRemoteNotificationsWithDeviceToken in the apple developer documentation for more information.

notify/app_name

This service will send messages to a registered device. The following parameters can be used:

message: The message to send

target: The desired state of the device, only devices that match the state will receive messages. To enable state tracking a registered device must have a device_tracking_id added to the [app_name]_apns.yaml file. If this id matches a device in known_devices.yaml its state will be tracked.

data:
badge: The number to display as the badge of the app.
sound: The name of a sound file in the app bundle or in the Library/Sounds folder.
category: Provide this key with a string value that represents the identifier property of the UIMutableUserNotificationCategory
content_available: Provide this key with a value of 1 to indicate that new content is available.

Checklist:

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

If the code does not interact with devices:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • Tests have been added to verify that the new code works.

@mention-bot
Copy link

@sam-io, thanks for your PR! By analyzing the history of the files in this pull request, we identified @balloob, @fabaff and @rmkraus to be potential reviewers.

hass = get_test_home_assistant()
self.assertFalse(notify.setup(hass, config))

def test_register_new_device(self):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

farcy v1.1

  • D102: Missing docstring in public method

@sam-io
Copy link
Contributor Author

sam-io commented Oct 8, 2016

How can I re-run the build? Seems like a random failure.

@fabaff
Copy link
Member

fabaff commented Oct 8, 2016

Is this the successor of #2984?

@sam-io
Copy link
Contributor Author

sam-io commented Oct 8, 2016

Yes

@kevinpanaro
Copy link
Contributor

awesome work here. you and @robbiet480 should chat, potentially.

@sam-io
Copy link
Contributor Author

sam-io commented Oct 11, 2016

@robbiet480 do you want me to do anything else to this or is it ok to merge?

@robbiet480
Copy link
Member

I just skimmed this, it looks fine. Need to take a closer look at the code first though. Will try my best to get that done today.

Copy link
Member

@pvizeli pvizeli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work. A smal change and we can merge it 👍

def get_service(hass, config):
"""Return push service."""
descriptions = load_yaml_config_file(
os.path.join(os.path.dirname(__file__), 'apns_services.yaml'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dont use a own service yaml. Add to service.yaml like other platform do...

DOMAIN = "apns"
APNS_DEVICES = "apns.yaml"
DEVICE_TRACKER_DOMAIN = "device_tracker"
SERVICE_REGISTER = "register"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you rename it apns_register to indicate that it is part of the apns platform?

@balloob balloob merged commit ae8a8e2 into home-assistant:dev Oct 18, 2016
@home-assistant home-assistant locked and limited conversation to collaborators Mar 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants