auchter / haaska

Home Assistant Alexa Skill Adapter
263 stars 61 forks source link

Alexa.PowerController #63

Open auchter opened 7 years ago

auchter commented 7 years ago

Found something interesting while issuing a "turn off" command to a media_player device that was exposed via the Video Skill API.

type object 'Alexa' has no attribute 'PowerController': AttributeError
Traceback (most recent call last):
File "/var/task/haaska.py", line 788, in event_handler
ha, event)
File "/var/task/haaska.py", line 404, in invoke
obj = make_class(allowed)(namespace, name, ha, event)
AttributeError: type object 'Alexa' has no attribute 'PowerController'

Looks like there's a new interface coming: Alexa.PowerController, with TurnOn and TurnOff methods. Couldn't find any documentation about this, though...

auchter commented 7 years ago

https://github.com/auchter/haaska/commit/72eb69a41a1847be6b93b13ca2ce6b26e5a7985c

That gets "turn off" and "turn on" working again for media_players

keatontaylor commented 7 years ago

Hmm, what voice command did you actually say?

I cannot seem to duplicate this behavior. Are your media players also exposed via the Smart Home Skill as well?

keatontaylor commented 7 years ago

Had to add Alexa.PowerController to the capabilities payload.

endpoint['capabilities'] = [
                        alexa_interface('Alexa.RemoteVideoPlayer'),
                        alexa_interface('Alexa.ChannelController'),
                        alexa_interface('Alexa.PlaybackController'),
                        alexa_interface('Alexa.PowerController')]

Also pure speculation, but I bet that in the coming weeks we'll see Amazon announce playback and power controls for some manufacturer of smart TV. So we may be getting volume controls soon too. :)

trisk commented 7 years ago

Looks like we also need Alexa.PercentageController for volume:

object 'Alexa' has no attribute 'PercentageController': AttributeError
Traceback (most recent call last):
File "/var/task/haaska.py", line 795, in event_handler
ha, event)
File "/var/task/haaska.py", line 411, in invoke
obj = make_class(allowed)(namespace, name, ha, event)
AttributeError: type object 'Alexa' has no attribute 'PercentageController'
keatontaylor commented 7 years ago

This is awesome!

keatontaylor commented 7 years ago

Looks like it is expecting something different in the response payload, as it seems to be always saying "something went wrong" when I try and issue commands. No errors in the log.

trisk commented 7 years ago

https://github.com/trisk/haaska/commit/a91c04ddf8d7315c629a88de29efa1dc474cf3e9 makes PercentageController function on the HA service call side, but still haven't figured out the response format so I get "I'm not quite sure what went wrong" after completing the command.

keatontaylor commented 7 years ago

Got another one. Traceback (most recent call last): File "/var/task/haaska.py", line 176, in invoke operator.attrgetter(name)(self)() AttributeError: 'PercentageController' object has no attribute 'AdjustPercentage'

keatontaylor commented 7 years ago

Apparently this too: https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/alexa-seekcontroller

BladeRunner68 commented 7 years ago

Guys, Amazon today released a major update for their Alexa smart home API - will be interested to see how you can use this with Haaska (excellent script BTW).

Fill your boots:

https://github.com/alexa/alexa-smarthome/tree/master/sample_messages

https://developer.amazon.com/blogs/alexa/post/bd91b3e6-9799-445e-9cfc-7e3e2d78980f/alexa-delivers-rich-easy-to-use-new-features-for-smart-home-consumers-and-developers

keatontaylor commented 7 years ago

Looks like they're unifying the API that they've created so far and taking steps to enhance features such as querying the state of devices, and from the sounds of it being able to trigger smart home devices via the alexa app with a graphical interface. (that would be nice)

I'm especially interested in the fact that they've broken the thermostat control away from the thermostat sensor, so we may see other "sensor" interfaces coming soon.