Question regarding AppDaemon service call

Hello all,

i am new to Home assistant and wanted to integrate gspread with the home assistant to realize a functionality. I want to use the notify service call to push a notification to my phone with some actionable items.

I created the below function to do the same.

def push_start_notification(self, kwargs):
    messagestr = "Start your work day"
    titlestr = "Log Start"
    datastr = """{
        "actions": [
            {
                "action": "logwend",
                "title": "Log Work End"
            }
        ]
    }"""
    self.call_service("notify/mobile_app_in2023", message = messagestr, title = titlestr, data = datastr)

Calling this function always leads to the following error
Code: 400, error: 400: Bad Request

The code functions perfectly when i remove the data = datastr argument from the call_service function.

Any help here will be deeply appreciated.

Are you sure that data expects a string?

Try defining datastr as a dictionary instead:

datastr = {
        "actions": [
            {
                "action": "logwend",
                "title": "Log Work End"
            }
        ]
    }

I had a similar issue when sending a file path as part of a notification, and the solution was to pass a dictionary instead of a string as the data parameter.

1 Like

Thank you so much. That worked.