-
Notifications
You must be signed in to change notification settings - Fork 58
-
Hello everyone,
I'm trying to send a message to my cell phone via pyscript and then automatically process the response I give.
Example code:
response = service.call("notify", "mobile_app_phone", return_response=True, message='Something happened', title='Dispatch Alert', data = {"actions":[ {"action":"Message1", "title":"Message1", "response": "Message1"}, {"action":"Message2", "title":"Message2", "response": "Message2"} ]})
Unfortunately, I always get the following error message:
ServiceValidationError: An action which does not return responses can't be called with return_response=True
Unfortunately, I can't find an answer anywhere. Why is this so? To my understanding, "notify" should deliver a response or not?
or do I have to read out my response differently?
Beta Was this translation helpful? Give feedback.
All reactions
Thanks, ALERTua your hint has put me on the right track to solve my problem.
To get the responses on a mobile app notification, you can use an event trigger to continue working with the response.
Example:
@event_trigger("mobile_app_notification_action")
def monitor_mobile_app_actions(**kwargs):
log.info(f"kwargs={kwargs}")
Replies: 2 comments 1 reply
-
alas, notify
method of mobile_app
integration doesn't have return_response
parameter
https://github.com/home-assistant/core/blob/dev/homeassistant/components/mobile_app/notify.py
Beta Was this translation helpful? Give feedback.
All reactions
-
Thanks, ALERTua your hint has put me on the right track to solve my problem.
To get the responses on a mobile app notification, you can use an event trigger to continue working with the response.
Example:
@event_trigger("mobile_app_notification_action")
def monitor_mobile_app_actions(**kwargs):
log.info(f"kwargs={kwargs}")
Beta Was this translation helpful? Give feedback.
All reactions
-
Amazing! I've been trying to figure this out as well. Thanks for the followup!
In case any newbies like myself see this, the kwargs contains the name of the action. So you could do something like:
if kwargs['action'] == "Message1":
# do some custom action
...
example of the kwargs:
kwargs={'trigger_type': 'event', 'event_type': 'mobile_app_notification_action', 'context': <homeassistant.core.Context object at 0x7fab14416ed0>, 'action': 'Message1'}
Beta Was this translation helpful? Give feedback.