From 3337107e79d8bfa623ba49c82e05b581b5bfde8d Mon Sep 17 00:00:00 2001 From: Michel Weimerskirch Date: Mon, 2 Oct 2017 11:29:31 +0200 Subject: [PATCH] Facebook Messenger notify component: add support for sending messages to specific page user IDs (#9643) --- homeassistant/components/notify/facebook.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/notify/facebook.py b/homeassistant/components/notify/facebook.py index ef85450ca63..db175c6b0a6 100644 --- a/homeassistant/components/notify/facebook.py +++ b/homeassistant/components/notify/facebook.py @@ -56,8 +56,15 @@ class FacebookNotificationService(BaseNotificationService): return for target in targets: + # If the target starts with a "+", we suppose it's a phone number, + # otherwise it's a user id. + if target.startswith('+'): + recipient = {"phone_number": target} + else: + recipient = {"id": target} + body = { - "recipient": {"phone_number": target}, + "recipient": recipient, "message": body_message } import json