Hi, this is a reproduction of my question on this thread
I need to pass these parameters to an AppDaemon call_service function:
{
"addon": "7be23ff5_dropbox_sync",
"input": {
"command": "upload"
}
}
but I don’t know how to define the nested data part.
This is what I’ve tried:
self.call_service("hassio/addon_stdin", addon="7be23ff5_dropbox_sync", input = "{'command':'upload'}")
but received this error on the addon “Upload Hassio snapshots to Dropbox” log:
"{'command':'upload'}"
jq: error (at <stdin>:1): Cannot index string with string "command"
[Info] Received message with command
[Error] Command not found:
Any help will be appreciated. Thanks!
Did you try just passing the dictionary? I’m guessing when it says “Cannot index string with string”, it’s calling input['command']
which would make me think the input is a dictionary, not a string: input={ 'command' : 'upload' }
Sorry, I’m not sure what do you mean by just passing the dictionary. The error i think is a classic python error, when the parser is trying to access the chars of the string (referring to it as an array of chars), but I’m not sure as I’m not fluent with python. Nevertheless, the solution should come by a correct way to pass nested object data through the AD function call. I think…
You wrote:
self.call_service("hassio/addon_stdin", addon="7be23ff5_dropbox_sync", input = "{'command':'upload'}")
I suggested you try:
self.call_service("hassio/addon_stdin", addon="7be23ff5_dropbox_sync", input = {'command':'upload'})
ah, ok. this one fails on AD log with this error:
2019-05-30 19:57:18.161832 WARNING AppDaemon: Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/appdaemon/appdaemon.py", line 586, in worker
funcref(self.sanitize_timer_kwargs(app, args["kwargs"]))
File "/config/appdaemon/apps/snapshot_schedule.py", line 26, in timer_callback
self.call_service("hassio/addon_stdin", addon="7be23ff5_dropbox_sync", input = {command:'upload'})
NameError: name 'command' is not defined
You forgot the the single quotes around command, it needs to be like this: {'command': 'upload'}
no, the code holds the ‘command’ (with quotes) but the log shows without it. not sure why.
I reallize this sounds silly but double check that - I can’t see how that would be possible. The code line in an exception shown in the log comes directly from the file python file.
F#$@ me, not only you were right, also it worked!
Thanks @TD22057 and @Burningstone !!
Don’t be so hard with yourself, rather learn from your mistakes
1 Like