Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

notify service.call no respons Error #697

Answered by EderBrach
EderBrach asked this question in Q&A
Discussion options

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?

You must be logged in to vote

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

Comment options

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

You must be logged in to vote
0 replies
Comment options

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}")

You must be logged in to vote
1 reply
Comment options

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'}
Answer selected by EderBrach
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /