Amazon Echo to Domoticz Bridge: switches, sensors & more

Alexa, Google Home and Siri

Moderator: leecollings

Madgeni
Posts: 1571
Joined: Friday 25 March 2016 17:43
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Amazon Echo to Domoticz Bridge: switches, sensors & more

Post by Madgeni »

You can actually test it remotely, if you use the app/site, you can add the Skill in, then run a discovery. It might freak someone out if they are at home, as it announces the devices it finds :D
Native Alexa skill and Google app - register at https://www.controlicz.com - https://twitter.com/Controlicz
User avatar
mack
Posts: 14
Joined: Friday 08 April 2016 8:23
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: Dallas, USA
Contact:

Re: Amazon Echo to Domoticz Bridge: switches, sensors & more

Post by mack »

One thing I think should be in the readme doc is to make sure your console is set to N. Virginia before creating a lambda function, since that's the only location currently supporting Smart Home Kit. The selector is in the upper right corner. Mine was set to Oregon, and it threw me for a little while.

My setup is mostly working. Only a few devices weren't discovered. Scenes and the regular switches work fine, but Alexa insists to telling me that the "command doesn't work on that device" after she's done it. I haven't had time to troubleshoot that yet :)
Madgeni
Posts: 1571
Joined: Friday 25 March 2016 17:43
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Amazon Echo to Domoticz Bridge: switches, sensors & more

Post by Madgeni »

Hi

I'll update that, you're 100% right.
It's not perfect, but there's a challenge between the way that Domoticz (and the individual vendors) present their switches, over how Alexa expects them, so it might well not be discovering all types of switch correctly. I can probably update it with a more generic type if you can get me some feedback.
You should be getting the response ok, but take a look at the logs, and let me know what the switch is coming back as etc. Maybe add in some console.logs to troubleshoot.
Native Alexa skill and Google app - register at https://www.controlicz.com - https://twitter.com/Controlicz
Madgeni
Posts: 1571
Joined: Friday 25 March 2016 17:43
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Amazon Echo to Domoticz Bridge: switches, sensors & more

Post by Madgeni »

oh, and you're welcome ;-)
Native Alexa skill and Google app - register at https://www.controlicz.com - https://twitter.com/Controlicz
Madgeni
Posts: 1571
Joined: Friday 25 March 2016 17:43
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Amazon Echo to Domoticz Bridge: switches, sensors & more

Post by Madgeni »

ok, i've updated the domapi.js to provide a generic switch type for Alexa, which should resolve your missing lights (don't forget it's currently only discovering switches in Domoticz that are deemed 'lights'), and hopefully should provide feedback, as that's not been a problem for this release (for me).
Native Alexa skill and Google app - register at https://www.controlicz.com - https://twitter.com/Controlicz
superczar
Posts: 65
Joined: Wednesday 14 January 2015 12:08
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: India
Contact:

Re: Amazon Echo to Domoticz Bridge: switches, sensors & more

Post by superczar »

Same problem as what Mack reported ..
I was able to get the switches and scenes as devices but Alexa comes back with a "command doesn't work on that device" prompt
Let me dig into the logs and see what I can find
Madgeni
Posts: 1571
Joined: Friday 25 March 2016 17:43
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Amazon Echo to Domoticz Bridge: switches, sensors & more

Post by Madgeni »

ok, that's really odd!
If you use the test payload on/off - you should get:
{
"header": {
"namespace": "Alexa.ConnectedHome.Control",
"name": "TurnOffConfirmation",
"payloadVersion": "2",
"messageId": "12232132"
},
"payload": {}
}

or similar in the execution result, and { status: 'OK', title: 'SwitchScene' } in the Log Output. If you're not seeing that, there's a problem!
Native Alexa skill and Google app - register at https://www.controlicz.com - https://twitter.com/Controlicz
superczar
Posts: 65
Joined: Wednesday 14 January 2015 12:08
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: India
Contact:

Re: Amazon Echo to Domoticz Bridge: switches, sensors & more

Post by superczar »

Here is what I get with the test payload

Execution result: succeeded

Code: Select all

{
  "header": {
    "namespace": "Alexa.ConnectedHome.Control",
    "payloadVersion": "2"
  },
  "payload": {}
}
Edit: Some more troubleshooting yields the following

Code: Select all

{
  "header": {
    "messageId": "01ebf625-0b89-4c4d-b3aa-32340e894688",
    "name": "TurnOffRequest",
    "namespace": "Alexa.ConnectedHome.Control",
    "payloadVersion": "2"
  },
  "payload": {
    "accessToken": "123",
    "appliance": {
      "additionalApplianceDetails": {
        "switchis": "On/Off",
        "WhatAmI": "light"
      },
      "applianceId": CHANGETHISTOANIDXINYOURDOMOTICZ
    }
  }
}
- The above Works for switching off switches (or TurnOnRequest works for switching them on) i.e. the lambda code seems to work
- The scene changer payload does not seem to work at all
- device discovery works i.e. the alexa configuration works as well
- For the switch requests that work in lambda testing (tried with x10 and rgbw) - a switch on or off command via the echo returns "That command does not work on that device" error
Last edited by superczar on Monday 27 June 2016 22:01, edited 1 time in total.
Madgeni
Posts: 1571
Joined: Friday 25 March 2016 17:43
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Amazon Echo to Domoticz Bridge: switches, sensors & more

Post by Madgeni »

ok, that's weird, the messageid appears to be missing for a start.
On the window on the left, in the execution results window, what's the output there?


edit - i'm assuming you've put a correct IDX in the bit where it says "CHANGEMEETC"?
Native Alexa skill and Google app - register at https://www.controlicz.com - https://twitter.com/Controlicz
superczar
Posts: 65
Joined: Wednesday 14 January 2015 12:08
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: India
Contact:

Re: Amazon Echo to Domoticz Bridge: switches, sensors & more

Post by superczar »

added some more debug info - the lambda test code seems to be working for switches (but not scenes)
Device discovery works too (so the alexa skill seems configured correctly)
however voice command returns a "command does not work on that device error"

Log from switch test code

Code: Select all


START RequestId: 4d0991c4-3ca2-11e6-9489-858dfe858127 Version: $LATEST
2016-06-27T20:04:05.705Z	4d0991c4-3ca2-11e6-9489-858dfe858127	Input { header: 
   { messageId: '01ebf625-0b89-4c4d-b3aa-32340e894688',
     name: 'TurnOffRequest',
     namespace: 'Alexa.ConnectedHome.Control',
     payloadVersion: '2' },
  payload: 
   { accessToken: '123',
     appliance: { additionalApplianceDetails: [Object], applianceId: 25 } } }
2016-06-27T20:04:07.019Z	4d0991c4-3ca2-11e6-9489-858dfe858127	{ status: 'OK', title: 'SwitchLight' }
END RequestId: 4d0991c4-3ca2-11e6-9489-858dfe858127
REPORT RequestId: 4d0991c4-3ca2-11e6-9489-858dfe858127	Duration: 1315.59 ms	Billed Duration: 1400 ms 	Memory Size: 128 MB	Max Memory Used: 59 MB	

Log from scene test code

Code: Select all

   

START RequestId: 88aa00d9-3ca2-11e6-8186-a554b0f42d0b Version: $LATEST
2016-06-27T20:05:45.695Z	88aa00d9-3ca2-11e6-8186-a554b0f42d0b	Input { header: 
   { messageId: '01ebf625-0b89-4c4d-b3aa-32340e894688',
     name: 'TurnOffRequest',
     namespace: 'Alexa.ConnectedHome.Control',
     payloadVersion: '2' },
  payload: 
   { accessToken: '123',
     appliance: { additionalApplianceDetails: [Object], applianceId: 4 } } }
2016-06-27T20:05:46.885Z	88aa00d9-3ca2-11e6-8186-a554b0f42d0b	{ status: 'ERR' }
END RequestId: 88aa00d9-3ca2-11e6-8186-a554b0f42d0b
REPORT RequestId: 88aa00d9-3ca2-11e6-8186-a554b0f42d0b	Duration: 1191.24 ms	Billed Duration: 1200 ms 	Memory Size: 128 MB	Max Memory Used: 59 MB	



Madgeni
Posts: 1571
Joined: Friday 25 March 2016 17:43
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Amazon Echo to Domoticz Bridge: switches, sensors & more

Post by Madgeni »

can you just put a console.log in both cases of the switch statement ("i'm in Switch") or ("i'm in Scene"), just to make sure it's calling the scene case? Also, silly Q, but you the scene you're controlling definitely has an IDX of 4?
Native Alexa skill and Google app - register at https://www.controlicz.com - https://twitter.com/Controlicz
superczar
Posts: 65
Joined: Wednesday 14 January 2015 12:08
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: India
Contact:

Re: Amazon Echo to Domoticz Bridge: switches, sensors & more

Post by superczar »

Madgeni wrote:can you just put a console.log in both cases of the switch statement ("i'm in Switch") or ("i'm in Scene"), just to make sure it's calling the scene case? Also, silly Q, but you the scene you're controlling definitely has an IDX of 4?
Here are the execution and console logs for a switch and a scene
Have also attached a screenshot of the devices - Both the switch and scene are captured there justt in case it helps with the debugging

Execution Log for Switch

Code: Select all

{
  "header": {
    "namespace": "Alexa.ConnectedHome.Control",
    "payloadVersion": "2"
  },
  "payload": {}
}
Console Log for Switch

Code: Select all


START RequestId: e6c2bec4-3d02-11e6-b3e6-631cdc78fced Version: $LATEST
2016-06-28T07:35:36.823Z	e6c2bec4-3d02-11e6-b3e6-631cdc78fced	Input { header: 
   { messageId: '01ebf625-0b89-4c4d-b3aa-32340e894688',
     name: 'TurnOffRequest',
     namespace: 'Alexa.ConnectedHome.Control',
     payloadVersion: '2' },
  payload: 
   { accessToken: '123',
     appliance: { additionalApplianceDetails: [Object], applianceId: 23 } } }
2016-06-28T07:35:38.124Z	e6c2bec4-3d02-11e6-b3e6-631cdc78fced	{ status: 'OK', title: 'SwitchLight' }
END RequestId: e6c2bec4-3d02-11e6-b3e6-631cdc78fced
REPORT RequestId: e6c2bec4-3d02-11e6-b3e6-631cdc78fced	Duration: 1364.86 ms	Billed Duration: 1400 ms 	Memory Size: 128 MB	Max Memory Used: 54 MB	


Execution log for scene

Code: Select all


{
  "header": {
    "namespace": "Alexa.ConnectedHome.Control",
    "payloadVersion": "2"
  },
  "payload": {}
}

Console Log for Scene

Code: Select all

START RequestId: 5c3593bf-3d03-11e6-bc26-778b70fdef7e Version: $LATEST
2016-06-28T07:38:52.295Z	5c3593bf-3d03-11e6-bc26-778b70fdef7e	Input { header: 
   { messageId: '01ebf625-0b89-4c4d-b3aa-32340e894688',
     name: 'TurnOffRequest',
     namespace: 'Alexa.ConnectedHome.Control',
     payloadVersion: '2' },
  payload: 
   { accessToken: '123',
     appliance: { additionalApplianceDetails: [Object], applianceId: 4 } } }
2016-06-28T07:38:52.888Z	5c3593bf-3d03-11e6-bc26-778b70fdef7e	{ status: 'ERR' }
END RequestId: 5c3593bf-3d03-11e6-bc26-778b70fdef7e
REPORT RequestId: 5c3593bf-3d03-11e6-bc26-778b70fdef7e	Duration: 626.62 ms	Billed Duration: 700 ms 	Memory Size: 128 MB	Max Memory Used: 54 MB	
Attachments
Domoticz Devices list
Domoticz Devices list
Capture.JPG (140.35 KiB) Viewed 2794 times
Madgeni
Posts: 1571
Joined: Friday 25 March 2016 17:43
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Amazon Echo to Domoticz Bridge: switches, sensors & more

Post by Madgeni »

ok, so there's clearly a problem with the responses, as the messageid isn't there.

Are your scenes groups or scenes? According to the Domoticz API documentation, you can only turn Scenes 'On' - Groups can be turned on/off. Can you try that, and also put the logging into the Switch statements?

We'll get there :)
Native Alexa skill and Google app - register at https://www.controlicz.com - https://twitter.com/Controlicz
Madgeni
Posts: 1571
Joined: Friday 25 March 2016 17:43
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Amazon Echo to Domoticz Bridge: switches, sensors & more

Post by Madgeni »

i've updated the domapi.js on github with some logging - i've tested it, and it's still working for me, with feedback. Can you try this one?

Thanks!
Native Alexa skill and Google app - register at https://www.controlicz.com - https://twitter.com/Controlicz
superczar
Posts: 65
Joined: Wednesday 14 January 2015 12:08
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: India
Contact:

Re: Amazon Echo to Domoticz Bridge: switches, sensors & more

Post by superczar »

Uploaded the new files from github and changed test code to TurnOnRequest

Test request

Code: Select all

{
  "header": {
    "messageId": "01ebf625-0b89-4c4d-b3aa-32340e894688",
    "name": "TurnOnRequest",
    "namespace": "Alexa.ConnectedHome.Control",
    "payloadVersion": "2"
  },
  "payload": {
    "accessToken": "123",
    "appliance": {
      "additionalApplianceDetails": {
        "WhatAmI": "scene"
      },
      "applianceId": 4
    }
  }
}
Response log

Code: Select all

START RequestId: b265cae9-3d12-11e6-91ee-a7521e434e0d Version: $LATEST
2016-06-28T09:28:40.704Z	b265cae9-3d12-11e6-91ee-a7521e434e0d	Input { header: 
   { messageId: '01ebf625-0b89-4c4d-b3aa-32340e894688',
     name: 'TurnOnRequest',
     namespace: 'Alexa.ConnectedHome.Control',
     payloadVersion: '2' },
  payload: 
   { accessToken: '123',
     appliance: { additionalApplianceDetails: [Object], applianceId: 4 } } }
2016-06-28T09:28:40.963Z	b265cae9-3d12-11e6-91ee-a7521e434e0d	I'm in the scene case
2016-06-28T09:28:41.827Z	b265cae9-3d12-11e6-91ee-a7521e434e0d	{ status: 'ERR' }
END RequestId: b265cae9-3d12-11e6-91ee-a7521e434e0d
REPORT RequestId: b265cae9-3d12-11e6-91ee-a7521e434e0d	Duration: 1193.56 ms	Billed Duration: 1200 ms 	Memory Size: 128 MB	Max Memory Used: 55 MB	
Madgeni
Posts: 1571
Joined: Friday 25 March 2016 17:43
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Amazon Echo to Domoticz Bridge: switches, sensors & more

Post by Madgeni »

I think i've got it -
It's my fault for not explaining this - so Domoticz manages Scenes differently to switches etc, and stores them in a different table, allowing them to have the same IDX.
Alexa can't (rather understandably) handle this, so i cheat - essentially converting the IDX into a number, add another number to it to provide a unique IDX.
When testing it, can you try 204 for the IDX, rather than 4?

Still not sure why you're not getting good feedback though, but this should fix the Scenes
Native Alexa skill and Google app - register at https://www.controlicz.com - https://twitter.com/Controlicz
superczar
Posts: 65
Joined: Wednesday 14 January 2015 12:08
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: India
Contact:

Re: Amazon Echo to Domoticz Bridge: switches, sensors & more

Post by superczar »

Sorry about the delayed response, had a rather demanding last few weeks at work
Was WFH today and managed to discover a rather nice piece of code at https://github.com/bwssytems/ha-bridge

I can confirn that it works perfectly well with with both Amazon echo and harmony
It's a lot easier for the significant other to use alexa for tasks with the HA bridge that I now have running on a spare Pi

It's a lot more intuitive to say "Alexa, turn on the TV/ turn on all lights" vs "Alexa, tell Jarvis to switch on the TV/Alexa, tell lifx to switch on all lights/alexa, trigger on porch"

I may move it to the synology or the domoticz pi perhaps but for now a separate pi running this doesn't hurt either..
Madgeni
Posts: 1571
Joined: Friday 25 March 2016 17:43
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Amazon Echo to Domoticz Bridge: switches, sensors & more

Post by Madgeni »

that's interesting work.
A note of caution - i'm assuming that this is now deprecated from Amazon, as it's not code that runs in the cloud, so there's a concern that they may change someone on their side in the longer term that breaks this.
And my use of the Smart Home skill doesn't require you to call 'Jarvis', rather simply say "Alexa, turn on the kitchen lights' etc.
Native Alexa skill and Google app - register at https://www.controlicz.com - https://twitter.com/Controlicz
superczar
Posts: 65
Joined: Wednesday 14 January 2015 12:08
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: India
Contact:

Re: Amazon Echo to Domoticz Bridge: switches, sensors & more

Post by superczar »

It is deprecated from amazon in the sense that it runs as a Hue emulator on your LAN so hopefully shouldn't break unless Hue changes their API which is unlikely..
It actually runs quite beautifully well - It's a one time task to manually add all scenes/switches but the results are worth it
Hopefully I shall have a light day at work one of these days so I can add it to the wiki :)
Madgeni
Posts: 1571
Joined: Friday 25 March 2016 17:43
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Amazon Echo to Domoticz Bridge: switches, sensors & more

Post by Madgeni »

That's a very neat solution :)
Native Alexa skill and Google app - register at https://www.controlicz.com - https://twitter.com/Controlicz
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest