Page 8 of 36

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

Posted: Friday 30 September 2016 11:29
by amz4u2nv
Thanks BigTed, that worked, got another question though.

I tried to test to discover my devices using the following request -
{
"header": {
"messageId": "6d6d6e14-8aee-473e-8c24-0d31ff9c17a2",
"name": "DiscoverAppliancesRequest",
"namespace": "Alexa.ConnectedHome.Discovery",
"payloadVersion": "2"
},
"payload": {
"accessToken": "123"
}
}

Do I need to change anything above, as I just copied and pasted- output was

START RequestId: 9e8ff964-86ef-11e6-b5ed-d7bb8711bc2d Version: $LATEST
END RequestId: 9e8ff964-86ef-11e6-b5ed-d7bb8711bc2d
REPORT RequestId: 9e8ff964-86ef-11e6-b5ed-d7bb8711bc2d Duration: 3000.89 ms Billed Duration: 3000 ms Memory Size: 128 MB Max Memory Used: 26 MB
2016-09-30T09:24:02.713Z 9e8ff964-86ef-11e6-b5ed-d7bb8711bc2d Task timed out after 3.00 seconds

Just tried doing this on US N Virginia for now.
Any ideas?

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

Posted: Friday 30 September 2016 11:34
by amz4u2nv
further to my last question - increase timeout from 3 to 10 - output is now different -

START RequestId: a69dc7e9-86f0-11e6-bca0-3bb75b085d1b Version: $LATEST
2016-09-30T09:31:23.248Z a69dc7e9-86f0-11e6-bca0-3bb75b085d1b Input { header:
{ messageId: '6d6d6e14-8aee-473e-8c24-0d31ff9c17a2',
name: 'DiscoverAppliancesRequest',
namespace: 'Alexa.ConnectedHome.Discovery',
payloadVersion: '2' },
payload: { accessToken: '123' } }
2016-09-30T09:31:24.522Z a69dc7e9-86f0-11e6-bca0-3bb75b085d1b SyntaxError: Unexpected token u
at Object.parse (native)
at Request._callback (/var/task/node_modules/domoticz-api/api/domoticz.js:69:49)
at self.callback (/var/task/node_modules/domoticz-api/node_modules/request/request.js:200:22)
at emitOne (events.js:77:13)
at Request.emit (events.js:169:7)
at Request.onRequestError (/var/task/node_modules/domoticz-api/node_modules/request/request.js:831:8)
at emitOne (events.js:77:13)
at ClientRequest.emit (events.js:169:7)
at TLSSocket.socketErrorListener (_http_client.js:256:9)
at emitOne (events.js:77:13)
END RequestId: a69dc7e9-86f0-11e6-bca0-3bb75b085d1b
REPORT RequestId: a69dc7e9-86f0-11e6-bca0-3bb75b085d1b Duration: 1338.87 ms Billed Duration: 1400 ms Memory Size: 128 MB Max Memory Used: 32 MB
Process exited before completing request

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

Posted: Friday 30 September 2016 11:53
by Madgeni
Yep, sorry - updated the README to reflect change from Event Source to Trigger

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

Posted: Friday 30 September 2016 12:08
by amz4u2nv
Thanks Madgeni - no worries.. should have spotted it.

Any ideas how to debug the following issue -
START RequestId: 9315fcb8-86f5-11e6-884b-dd98068285b9 Version: $LATEST
2016-09-30T10:06:40.841Z 9315fcb8-86f5-11e6-884b-dd98068285b9 Input { header:
{ messageId: '01ebf625-0b89-4c4d-b3aa-32340e894688',
name: 'TurnOffRequest',
namespace: 'Alexa.ConnectedHome.Control',
payloadVersion: '2' },
payload:
{ accessToken: '123',
appliance: { additionalApplianceDetails: [Object], applianceId: 9 } } }
2016-09-30T10:06:41.061Z 9315fcb8-86f5-11e6-884b-dd98068285b9 I'm in the Light case
2016-09-30T10:06:41.942Z 9315fcb8-86f5-11e6-884b-dd98068285b9 SyntaxError: Unexpected token u
at Object.parse (native)
at Request._callback (/var/task/node_modules/domoticz-api/api/domoticz.js:69:49)
at self.callback (/var/task/node_modules/domoticz-api/node_modules/request/request.js:200:22)
at emitOne (events.js:77:13)
at Request.emit (events.js:169:7)
at Request.onRequestError (/var/task/node_modules/domoticz-api/node_modules/request/request.js:831:8)
at emitOne (events.js:77:13)
at ClientRequest.emit (events.js:169:7)
at TLSSocket.socketErrorListener (_http_client.js:256:9)
at emitOne (events.js:77:13)
END RequestId: 9315fcb8-86f5-11e6-884b-dd98068285b9
REPORT RequestId: 9315fcb8-86f5-11e6-884b-dd98068285b9 Duration: 4574.50 ms Billed Duration: 4600 ms Memory Size: 128 MB Max Memory Used: 30 MB
Process exited before completing request

I can't see the line numbers where it is complaining about - "SyntaxError: Unexpected token u"
Thought it could be authorization problem, so updated it to use amazon - but still getting the same issue.

Many thanks

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

Posted: Friday 30 September 2016 13:01
by amz4u2nv
I got passed the error above, just in case anyone has the same issue -
my domoticz external address is https, so request wasn't able to sort out the certificate - i changed the code to -

Domoticz.prototype._request = function (url, callback) {
var self = this;

request({
"rejectUnauthorized": false,
"url": url.toString(),
"method": "GET",
},
function (error, res, data)
{
// console.log("URL RES" +res);
// console.log("URL ERROR" +error);
//next line new
// var stringify = JSON.stringify(data)
// callback(error, self._toLowerCaseResult(JSON.parse(stringify)));
console.log('Data hello '+data);
callback(error, self._toLowerCaseResult(JSON.parse(data)));
});
};

found the error by logging the error variable.

But another issue, the test works fine, but alexa app doesn't pickup the devices...cant see anything in cloud watch logs...

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

Posted: Friday 30 September 2016 13:17
by amz4u2nv
ok got it to discover, had to setup the Ireland one and make that the default. After that all devices were discovered. Can't wait to get home and try it via voice.
Thanks for all your help.
Amz

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

Posted: Friday 30 September 2016 13:35
by Madgeni
Thanks amz4u2nv! - i'll take a look at your change (as it's a change to the module I use, not one I wrote) - should be able to get it pulled into his master though, which would be a massive improvement in security

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

Posted: Friday 30 September 2016 15:11
by Lard2010
So I've now got the skill calling and executing the lambda. Thanks everyone for your input.

The problem I have now is I still don't get any devices discovered. When I look at the cloudwatch logs, though I see that my devices are being reported multiple times, for example device 1 has been reported about 20 times. This leads to a very long run time (I assume it's longer than the 20 seconds allowed in the Smart Home Skills discovery) and it either times out at the lambda end, or, if I set the timeout very high (30s) on the lambda side, the discovery itself seems to time out at the skill end.

Upshot is: Why are my devices being reported multiple times?

* Edit to add: For example there are multiple groups (which contain all my used dimmer devices ) that begin with this header:

* 2016-09-30T13:20:33.375Z a37d8f63-8710-11e6-8656-d56c32a66d28 here is each devicetype - Dimmer

* Obviously the timestamp changes, but there must be 100+ of these in the log for each execution.

* For the record I have 180 entries in my domoticz devices table, 80 of which are 'Used' devices.


Cheers,

Lard

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

Posted: Friday 30 September 2016 17:39
by Madgeni
Again, part my code, part the module I use for Node.
As it was for my own benefit, efficiency wasn't my primary concern!
Currently refactoring it for efficiency :-)

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

Posted: Friday 30 September 2016 20:44
by l0gic
Hi Madgeni,
I was working with yesterdays fully monty code and with the same version of the code installed in Dublin and N Virginia (default) calling for a discovery via Alexa, it ran the code in Dublin but failed to return and devices to Alexa.
OA is via your latest suggestion 'OA lite' from earlier today.
I've now changed to today's code and I have discovered 55 devices OK (all lighting related obviously) again invoked in Dublin.
So, I have working service and can control lights by voice ok. - Nice one!

I'm wondering if there is a time out value that prevents the results returning to Alexa?
Running with just the lighting subset devices are discovered, grabbing lots more and it fails to discover any.

Anyhow, thought you would be pleased to hear of a positive report back!

Thanks for a ll the work you are putting into this, it's appreciated.


edit - I've noticed that some switches are not listed. Running a discover from Lambda does not find them. Some other switches of the same type are found however. I'll have another look tomorrow - wine is calling :)

ATB

Kevin

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

Posted: Friday 30 September 2016 21:45
by Lard2010
All working now. Thanks for all your efforts, Madgeni. You must allow be to buy you a beer.

Lard

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

Posted: Saturday 01 October 2016 8:35
by Madgeni
cheers guys - i have no problem working on this, it's good practice, and a useful bit of work :)

Really pleased that it's of some use - will definitely work on speed, and functionality changes. When I get something 'stable', i'll release it

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

Posted: Saturday 01 October 2016 16:07
by l0gic
Ok, had a look at the situation.
I have 56 items in the switches tab in domoticz.
I have 9 scenes in the scenes tab.
All 9 scenes are found and listed as accessible by Alexa.
47 (56 - 9) switch items are found and listed by Alexa.

Scenes have group idx numbers of 1,2,3,4,5,6,10,11,12
Missing switches have idx numbers of 11,12,13,14,22,23,24,26
idx numbers 1,6 are temperature devices
idx numbers 2,3,4,5 are not used for devices (probably been deleted back in time)
idx numbers 10,11,12 are switches. 10 was found but 11 & 12 are missing.

The 9 scenes / 9 devices missing looks to be a bit of a coincidence I guess?

Hope this helps

Kevin

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

Posted: Saturday 01 October 2016 16:25
by Bigted
I had some devices not found in the same sort of range, I deleted the devices in Domoticz and re-added them, they were given a new number which were picked up

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

Posted: Sunday 02 October 2016 0:45
by amz4u2nv
I am getting the same issues where the devices are not found.
I checked the url used and it brings back whole the devices via the browser.
But for some reason I think via lambda it only brings back a certain amount of devices. I had to make some of my devices and scenes hidden using $ in front of the device name and re-run the alexa discover devices, it then picks up the missing devices.
I can't see anything in the code that would put a limit of how many devices should be discovered. Tried up - ing the timeout and memory allocated, didn't make any effect.
So as a workaround you can hide the devices and incrementally discover them on alexa.
Let me know if you find a better solution.

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

Posted: Sunday 02 October 2016 20:26
by l0gic
Guys,
Spent a bit of time reading up on Alexa.
Using the Alexa Smart Home Skill API only offers preset controls i.e. turn on/off lights set various temperatures.
I cant see any option to read a value e.g. what is the front room temperature.
I'm guessing in order to do that the Custom Interaction Model mode will need to be used.
Which is a shame.

I'll look into it a bit more just in case I've missed anything.

However it is looking like reading temperatures or any measuring device will need to be done the longer custom way.
I'll be interested in investigating this as I do have a lot of read only devices.

ATB
Kevin

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

Posted: Monday 03 October 2016 10:24
by Madgeni
Yep, it's currently limited in its speech. It's either a full rewrite for a custom skill, or hope they extend the range of interaction. I know they have a roadmap for the Smart Home Skill, they just won't share it with us :-)
I'll look into reasons for discovery issues. Currently refactoring, so will add it to the list!

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

Posted: Friday 07 October 2016 21:11
by y1ann1s
Hi I have a fibaro dimmer in domoticz and I try to use it from alexa, the turn on /off command work fine
but the dim command fail

Any ideas?

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

Posted: Friday 07 October 2016 22:59
by deennoo
Waiting for this in France, got a question : is there a way to use it as a tts speaker for notification ?

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

Posted: Saturday 08 October 2016 11:06
by blackdog65
From what I can see there is no immediate plan to roll out into Europe.
There is currently no way to get notifications, even simple reminders are just a sound with no clue as to what you are being reminded of.
No IFTTT, no shopping, no true calendar/to-do integration. Only really ready for US market.

Mine is now boxed up ready for return. I'll wait for Google Home.