Wiki source code of openHAB with Amazon Alexa Skill
Last modified by Normann P. Nielsen on 2025/12/12 15:15
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | = Topics = | ||
| 2 | |||
| 3 | {{toc/}} | ||
| 4 | |||
| 5 | |||
| 6 | {{success}}This page is very much WIP - Work In Progress, I have not a complete understanding of the group and tags used in my files ;) So there is room for some serious improvement.{{/success}} | ||
| 7 | |||
| 8 | |||
| 9 | |||
| 10 | |||
| 11 | = Alexa Skill with openHAB = | ||
| 12 | |||
| 13 | The setup itself is described here and works ok - [[https://www.openhab.org/docs/ecosystem/alexa/]] - the use of [[https://myopenhab.org/]] has a few benifits: 1) Takes care of the oAuth2 authentification precess and 2) You dont need to open for openHAB in Your firewall. | ||
| 14 | |||
| 15 | After the setup I could not get my.openhab.com to talk to my local openHAB, I saw these in the openhab.log: | ||
| 16 | |||
| 17 | |||
| 18 | {{code}} | ||
| 19 | 2017-11-05 17:34:43.985 [ERROR] [io.openhabcloud.internal.CloudClient] - Socket.IO 4 error: not authorized | ||
| 20 | {{/code}} | ||
| 21 | |||
| 22 | but after a while and a few UUID/Socket entering and restarts it suddenly worked.... I never figured out why... | ||
| 23 | |||
| 24 | |||
| 25 | |||
| 26 | After the setup, in went onto [[https://alexa.amazon.com/spa/index.html#appliances]] and added the skill: | ||
| 27 | |||
| 28 | [[image:Screenshot 2019-01-27 at 16.05.24.png]] | ||
| 29 | |||
| 30 | |||
| 31 | |||
| 32 | Then I created some files for binding the speach to Alexa and the (Zensehome) Things together. | ||
| 33 | |||
| 34 | Refer to [[OpenHAB with Zensehome>>Main.information-technology.openhab-with-zensehome]] . The Channel is the relation to a [[Thing>>https://www.openhab.org/docs/concepts/things.html]]; the "mqtt:topic:61a4bec6:kitchen-light" is the unique identifier. | ||
| 35 | |||
| 36 | |||
| 37 | {{code language="/etc/openhab2/items/alexa.items"}} | ||
| 38 | Switch Kitchen_Light "Kitchen Light" <light> (Kitchen) ["Lighting"] {channel="mqtt:topic:61a4bec6:kitchen-light"} | ||
| 39 | Switch Dinner_Table_Light "Dinner Table Light" <light> (Kitchen) ["Lighting"] {channel="mqtt:topic:61a4bec6:alrum-light"} | ||
| 40 | Switch Bedroom_Light "Bedroom Light" <light> (Bedroom) ["Lighting"] {channel="mqtt:topic:61a4bec6:bedrom-light"} | ||
| 41 | Switch Toke_Light "Toke Ceiling Light" <light> (TokesRoom) ["Lighting"] {channel="mqtt:topic:61a4bec6:toke-light"} | ||
| 42 | Switch Christopher_Light "Christopher Ceiling Light" <light> (ChristhopersRoom) ["Lighting"] {channel="mqtt:topic:61a4bec6:christopher-light"} | ||
| 43 | Switch Large_bathroom_Light "Large Bathroom Light" <light> (LargeBathroom) ["Lighting"] {channel="mqtt:topic:61a4bec6:large-bathroom"} | ||
| 44 | Switch Small_Bathroom_Light "Small Bathroom Light" <light> (SmallBathroom) ["Lighting"] {channel="mqtt:topic:61a4bec6:small-bathroom"} | ||
| 45 | Switch TV_Light "TV Light" <light> (LivingRoom) ["Lighting"] {channel="mqtt:topic:61a4bec6:livingroom-floor-switch-south"} | ||
| 46 | Switch Vintrine_Light "Vitrine Light" <light> (LivingRoom) ["Lighting"] {channel="mqtt:topic:61a4bec6:livingroom-floor-switch-west"} | ||
| 47 | Switch Redlamps_Light "Redlamps Light" <light> (LivingRoom) ["Lighting"] {channel="mqtt:topic:61a4bec6:livingroom-ceiling-north"} | ||
| 48 | Switch Office_Light "Office Light" <light> (Office) ["Lighting"] {channel="mqtt:topic:61a4bec6:office-ceiling"} | ||
| 49 | {{/code}} | ||
| 50 | |||
| 51 | |||
| 52 | {{code language="/etc/openhab2/items/group.items"}} | ||
| 53 | Group House | ||
| 54 | Group Livingroom (House) | ||
| 55 | Group Kitchen (House) | ||
| 56 | Group Bedroom (House) | ||
| 57 | Group TokesRoom (House) | ||
| 58 | Group ChristophersRoom (House) | ||
| 59 | Group LargeBathRoom (House) | ||
| 60 | Group SmallBathRoom (House) | ||
| 61 | Group Office (House) | ||
| 62 | |||
| 63 | Switch All_Lights "All Lights" ["Lighting"] | ||
| 64 | {{/code}} | ||
| 65 | |||
| 66 | |||
| 67 | |||
| 68 | Then I went back to Amazon and scanned for Devices. | ||
| 69 | |||
| 70 | = Scanning for Devices = | ||
| 71 | |||
| 72 | This little movie shows a rescan of devices: | ||
| 73 | |||
| 74 | {{video url="http://youtube.com/watch?v=ssixhKuooEY" /}} | ||
| 75 | {{error}}Notice the "Dinner Table Light" is standing as offline - currently that is a unresolved issue....{{/error}} | ||
| 76 | |||
| 77 | |||
| 78 | |||
| 79 | |||
| 80 | |||
| 81 | |||
| 82 | = Testing = | ||
| 83 | |||
| 84 | During testing - I did a tail on the Log from [[OpenHAB with Zensehome>>Main.information-technology.openhab-with-zensehome]] to see the commands being passed to the "Java Application as Bridge": | ||
| 85 | |||
| 86 | |||
| 87 | {{code}} | ||
| 88 | Jan 26, 2019 1:10:37 PM zensemqtt.Log logging | ||
| 89 | INFO: New message with topic: zense/execute/18324, Message: ON | ||
| 90 | Jan 26, 2019 1:10:47 PM zensemqtt.Log logging | ||
| 91 | INFO: New message with topic: zense/execute/18324, Message: OFF | ||
| 92 | Jan 26, 2019 1:11:37 PM zensemqtt.Log logging | ||
| 93 | INFO: New message with topic: zense/execute/16476, Message: ON | ||
| 94 | Jan 26, 2019 3:39:52 PM zensemqtt.Log logging | ||
| 95 | INFO: New message with topic: zense/execute/18324, Message: ON | ||
| 96 | Jan 26, 2019 3:56:47 PM zensemqtt.Log logging | ||
| 97 | INFO: New message with topic: zense/execute/18324, Message: ON | ||
| 98 | Jan 26, 2019 5:23:39 PM zensemqtt.Log logging | ||
| 99 | INFO: New message with topic: zense/execute/18324, Message: ON | ||
| 100 | Jan 27, 2019 12:08:51 PM zensemqtt.Log logging | ||
| 101 | INFO: New message with topic: zense/execute/18324, Message: ON | ||
| 102 | Jan 27, 2019 12:27:12 PM zensemqtt.Log logging | ||
| 103 | INFO: New message with topic: zense/execute/18324, Message: OFF | ||
| 104 | {{/code}} |