philchillbill wrote: ↑Sunday 24 November 2019 8:53
It’s called api_reportState in the original.
Sent from my iPhone using Tapatalk
Hello, thanks for your support. I did the test yesterday but getting this error:
1)
File "./reportstate.py", line 113, in main
data = AlexaSmartHome.api_reportState(endpoint, token)
File "/home/pi/domoticz/scripts/python/alexa/AlexaSmartHome.py", line 745, in api_reportState
properties.extend(interface.serializeProperties())
File "/home/pi/domoticz/scripts/python/alexa/AlexaSmartHome.py", line 138, in serializeProperties
prop_value = self._endpoint.getProperty(prop_name)
AttributeError: 'Domoticz' object has no attribute 'getProperty'
Plus I uploaded on aws the AlexaSmartHome.py and the DomoticzHandler.py included in the dev branch and reloaded the skill but then Alexa is not able to handle the devices on domoticz:
2)
Function Logs:
START RequestId: 613a7bfc-a5bd-4a02-9e8b-c7cccb629723 Version: $LATEST
Traceback (most recent call last):
File "/var/task/AlexaSmartHome.py", line 334, in invoke
return operator.attrgetter(name)(self)(request)
File "/var/task/AlexaSmartHome.py", line 372, in TurnOn
endpoint = self.handler.getEndpoint(request)
File "/var/task/DomoticzHandler.py", line 400, in getEndpoint
endpoint = getEndpointById(request['endpoint']['endpointId'])
NameError: name 'getEndpointById' is not defined
END RequestId: 613a7bfc-a5bd-4a02-9e8b-c7cccb629723
To bypass the first error I changed the properties.extend(interface.serializeProperties()) in properties.append(interface.serializeProperties())
For the second error I updated the line 400 of the DomoticzHandler.py script:
endpoint = self.getEndpointById(request['endpoint']['endpointId'])
And now I'm receiving this error from the reportstate.py script:
Traceback (most recent call last):
File "./reportstate.py", line 122, in <module>
main(sys.argv[1:])
File "./reportstate.py", line 117, in main
response = requests.post(ALEXA_URI, headers=headers, json=data)
File "/usr/lib/python3/dist-packages/requests/api.py", line 110, in post
return request('post', url, data=data, json=json, **kwargs)
File "/usr/lib/python3/dist-packages/requests/api.py", line 56, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 474, in request
prep = self.prepare_request(req)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 407, in prepare_request
hooks=merge_hooks(request.hooks, self.hooks),
File "/usr/lib/python3/dist-packages/requests/models.py", line 305, in prepare
self.prepare_body(data, files, json)
File "/usr/lib/python3/dist-packages/requests/models.py", line 445, in prepare_body
body = complexjson.dumps(json)
File "/usr/lib/python3.5/json/__init__.py", line 230, in dumps
return _default_encoder.encode(obj)
File "/usr/lib/python3.5/json/encoder.py", line 198, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python3.5/json/encoder.py", line 256, in iterencode
return _iterencode(o, 0)
File "/usr/lib/python3.5/json/encoder.py", line 179, in default
raise TypeError(repr(o) + " is not JSON serializable")
TypeError: <generator object AlexaInterface.serializeProperties at 0xb6981240> is not JSON serializable
So I'm able to get a valid access token but the body of the request is not a json, I guess because it is mandatory to extend the properties array instead of append. Maybe the first error is due to an error with the definition of the contact sensor in domoticz?