Amazon Echo and Alexa

Begonnen von andrejs, 03 Oktober 2015, 23:32:23

Vorheriges Thema - Nächstes Thema

andrejs

Erwin,
I am not familiar to SONOS module and Speak command so I just want to clarify what this command/function do. Please correct If I am wrong the purpose of Speak function is to send some text to SONOS speaker to be spoken (text to speach conversion)?
How does it look the syntax of the speak command (for switching some device is "set [name od device] on")?     

Andrej

erw85

Hello Andrej,

Yes, the Speak command uses e.g. Google Text to Speech to generate voice output.

It's used e.g. like this:
set Sonos_My_Room Speak 30 en Phrase to say.
With "30" = volume; "en" = english language; "Phrase to say" = text to be converted.

If you need help regarding testing, let me know!
Thanks in advance,
Erwin




andrejs

Erwin,
is there any possibility to avoid volume and language parameters and the default values for both of them (volume and language) are defined in Sonos module?

Andrej

erw85

Zitat von: andrejs am 16 Januar 2016, 01:24:02
Erwin,
is there any possibility to avoid volume and language parameters and the default values for both of them (volume and language) are defined in Sonos module?

Andrej

My opinion is that your module should't have such a default value requirement regarding other modules, e.g. like Sonos.
If possible your SRSet/SRStater/SRGeneral attributes should support a syntax to build custom command strings, e.g. use one or multiple slot types and (matched/unmatched) values for other modules.

Perhaps we could first discuss, how such a syntax could look like. The DOIF-module could be partly an inspiration as it supports many use cases. E.g. see the examples also in the German docu of it.

Then your module could have a very wide usage spectrum and not only the example with the Sonos Speak command.

Kind regards,
Erwin



andrejs

I managed to change the script in order to make possibility to create default SRstater,SRset attributes for devices. The script automaticly creates the default SRset, SRstater attributes after the FHEM server is started (90 seconds after the module loaded because I have problems to get list of all sets without any delay). For details see explanations below. The solution is not the best one but this what I can do now. Any other ideas are more then welcome.

Module 77_ECHO.pm - in order to understand the logic of Echo module please read the first post http://forum.fhem.de/index.php/topic,41754.0.html

Define
Define <name> ECHO

Set
Set <name> createattr

The script create defaults SRset, SRstater attributes for each device. The default SR attributes are created for the following devices and readings:
•   SRword attriibute must be defined/created for device
•   Copy files SRreading.csv and SRrvalue.csv to fhem directory. The name of files can be changes but then you should also change attribute SRimpfile 

SRreading.csv – in the file are 4 fields separated by comma

Field 1 – fhem name of the reading
Field 2 – english name of the reading
Field 3 – english name of measure unit
Field 4 – the word/command before the name of the device in attribute SRset

Example for FS20 switch and CUL_HM radiator valve
on,on,,switch
off,off,,switch
desired-temp,desired temperature,degrees Celsius,
measured-temp,measured temperature,degrees Celsius,

SRrvalue.csv – in the file are 3 fields separated by comma
Field 1 – fhem name of the reading
Field 2 – fhem value of the reading
Field 3 – english name of value

Example for CUL_HM radiator valve
desired-temp,17.0,seventeen point zero
desired-temp,21.0,twentyone point zero
controlMode,auto,automatic

Get
get <name of echo device> alexa <name of fhem device>
show API data for chosen device in json format used in index.js

get <name of echo device> intentschema
show Intent Schema which should be copied to Interaction module of Alexa Skill

get <name of echo device> uterances
show Sample Uteranaces which should be copied to Interaction module of Alexa Skill

get <name of echo device> attributes
show all defined SRset, SRstater attributes of devices

get <name of echo device> showsets
show for each devices all available sets/readings

get <name of echo device> stateall
show API data for all device in json format

Readings
request – show the last request from alexa

Attributes
SRexpfile
Possible values: 0 and 1
Default value: 0
The Intentschema and Sample Utranances using get command are written in files if the value is 1. The files are written in FHEM directory.

SRfrontset
Defualt value: set
It defines the first word in attribute SRset of each device when the SR attributes are created when »set <name of echo device> createattr« is used.

SRgeneral
Default value: current time:Time is *11,current day:Today is *10
The intention of this  attribute is to define general question for Alexa and get some answers.

Syntax: request1, request2,.....

Each request is divided by comma. In the request two elements should be present question and answer divided by :. Two parameters can be used in element answer:
-   *10 – get current date
-   *11 – get current time

Examples for SRgeneral
thank you:you are welcome,go to sleep:good night and sleep well,current time:Time is *11,current day:Today is *10

SRimpfile
Default value: SRreading.csv,SRrvalue.csv
The names of files separated by comma to define default SR attributes of devices
For details see above - Set <name> createattr.

SRoverwrite
Possible values: 0 and 1
Default value: 0
If the value of SRoverwrite is 1 the exsisting SRstater,SRreading attribute of devices will be overwritten when »set <name of echo device> createattr« is used.

SRintdefault
Default value: SRWord
The name of attribute where the english name of device can be found

SRintents
Default value: SRset:LITERAL#NUMBER,SRstater:LITERAL,SRgeneral:LITERAL
This attribute is used to create Intent Schema with get <name of echo device> intentschema

SRword
english name of echo device

AmunRe

#35
Hello All,


First of all, very great Modul!

It takes some time to get it working, but now it is fine.


I have a problem with my "get uterances". I got all SRset value but no one of SRstater.

Example:
define ts_aussen USBWX 2
attr ts_aussen SRstater *1 (temperature:temperature:degrees Celsius)
attr ts_aussen SRword outside
attr ts_aussen alias Außen
attr ts_aussen room Uebersicht,Wetter

And now my "get uterances".

SRset set {bathroom switch|litdev} {on|litrea}
SRset set {bathroom switch|litdev} {off|litrea}
SRset switch {onkyo|litdev} {off|litrea}
SRset  switch {onkyo|litdev} {on|litrea}
SRset set {onkyo|litdev} {input|litrea} {tv|litval}
SRset  set {onkyo|litdev} {input|litrea} {squeeze|litval}
SRset  set {onkyo|litdev} {volume up|litrea}
SRset  set {onkyo|litdev} {volume down|litrea}
SRset set {onkyo|litdev} {volume|litrea} to {ten|numval}
SRset set {onkyo|litdev} {volume|litrea} to {twenty|numval}
SRset set {onkyo|litdev} {volume|litrea} to {thirty|numval}
SRset set {onkyo|litdev} {mute|litrea} to {on|litval}
SRset set {onkyo|litdev} {mute|litrea} to {off|litval}
SRset set {playlist|litrea} of {squeeze livingroom|litdev} to {my playlist|litval}
SRset set {squeeze livingroom|litdev} {next|litrea}
SRset set {channel|litrea} of {kodi livingroom|litdev} to {sixxt|numval}
SRgeneral {good night|litrea}
SRgeneral {thank you|litrea}
SRgeneral {current time|litrea}
SRgeneral {current day|litrea}
SRgeneral {what time is it|litrea}
SRgeneral {what day is it|litrea}
SRset set {tv|litdev}{on|litrea}
SRset set {tv|litdev} {off|litrea}


Well, i also found a bug.

This 3 things wont work.
SRset set {onkyo|litdev} {volume|litrea} to {ten|numval}
SRset set {onkyo|litdev} {volume|litrea} to {twenty|numval}
SRset set {onkyo|litdev} {volume|litrea} to {thirty|numval}

He always set the thirty. And Alexa understand the 10 when i have a look at the history
4 x Echo Dot, HMLAN Gateway, und diverse HM Komponenten, Philips Hue + OSRAM Plugs

andrejs

Hi,
first thank you to find the bug. You are right the node.js script does not work when the intent slot "numval" is used. I propose to change numval to litval in Utterances:
SRset set {onkyo|litdev} {volume|litrea} to {ten|litval}
SRset set {onkyo|litdev} {volume|litrea} to {twenty|litval}
SRset set {onkyo|litdev} {volume|litrea} to {thirty|litval}   

I also corrected the module 77_ECHO.pm in order to write litval instead of numval.

Andrej

AmunRe

I think i found the next one.

Don't know why, but i have a dummy called Playstation and a Dummy called TV

Both are defined with SRWord and SRSet as Playstation and TV. Both with SRSet of turn (on:on) the *1,turn (off:off) the *1.

When i start TV it works fine. But the Playstation won't work.

When i'm testing it at Amazon my response is
Zitatturn (on:on) The remote endpoint could not be called, or the response it returned was invalid.

SRset turn {on|litrea} the {playstation|litdev}
SRset turn {off|litrea} the {playstation|litdev}

SRset turn {on|litrea} the {tv|litdev}
SRset turn {off|litrea} the {tv|litdev}


Can u help me a bit?
4 x Echo Dot, HMLAN Gateway, und diverse HM Komponenten, Philips Hue + OSRAM Plugs

andrejs

Sorry for my late reply, I am not very often on the forum. Can you please tell me how both dummies (TV, Playstation) are defined in FHEM and which FHEM syntax is used to switch both dummies?

Andrej 

AmunRe

Zitat von: andrejs am 25 April 2016, 23:37:29
Sorry for my late reply, I am not very often on the forum. Can you please tell me how both dummies (TV, Playstation) are defined in FHEM and which FHEM syntax is used to switch both dummies?

Andrej

hi Andrej,

No Problem.

define TV dummy
attr TV userattr lightSceneParamsToSave lightSceneRestoreOnlyIfChanged:1,0
attr TV SRset turn (on:on) the *1  {I turned on the *1 },turn (off:off) the *1 {I turned off the *1}
attr TV SRstater *1 (state:state)
attr TV SRword TV
attr TV room Wohnzimmer
attr TV setList on off



define PS3 dummy
attr PS3 SRset turn (on:on) the *1,turn (off:off) the *1
attr PS3 SRword Playstation
attr PS3 room Wohnzimmer
attr PS3 setList on off



The Syntax is just

set TV on/off
set PS3 on/off


Thanks for your help!
4 x Echo Dot, HMLAN Gateway, und diverse HM Komponenten, Philips Hue + OSRAM Plugs

andrejs

Strange because everything is defined as it should be and also tv works fine. Have you maybe for some other device defined Sword attribute as playstation?
What do you get if you make a test in AWS Lamda and use the following code (enter your applicationid) for "input test event":

{
  "session": {
    "new": false,
    "sessionId": "session1234",
    "attributes": {},
    "user": {
      "userId": null
    },
    "application": {
      "applicationId": "amzn1.echo-sdk-ams.app.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
    }
  },
  "version": "1.0",
  "request": {
    "intent": {
      "slots": {
        "litdev": {
          "name": "litdev",
          "value": "playstation"
        },
        "litrea": {
          "name": "litrea",
          "value": "on"
        }
      },
      "name": "SRset"
    },
    "type": "IntentRequest",
    "requestId": "request5678"
  }
}

AmunRe

#41
Zitat{
  "errorMessage": "Process exited before completing request"
}

The Logoutput:
ZitatSTART RequestId: 754b5cb5-0fb1-11e6-a2ae-ad08cbb0d4ae Version: $LATEST
2016-05-01T15:29:14.679Z   754b5cb5-0fb1-11e6-a2ae-ad08cbb0d4ae   session applicationId: amzn1.echo-sdk-ams.app.e5cdc66d-xxxxxxxx
2016-05-01T15:29:14.680Z   754b5cb5-0fb1-11e6-a2ae-ad08cbb0d4ae   dispatch intent = SRset
2016-05-01T15:29:14.680Z   754b5cb5-0fb1-11e6-a2ae-ad08cbb0d4ae   { slots:
   { litdev: { name: 'litdev', value: 'playstation' },
     litrea: { name: 'litrea', value: 'on' } },
  name: 'SRset' }
2016-05-01T15:29:15.437Z   754b5cb5-0fb1-11e6-a2ae-ad08cbb0d4ae   TypeError: Cannot read property 'Value' of undefined
    at IncomingMessage.<anonymous> (/var/task/index.js:161:57)
    at emitNone (events.js:72:20)
    at IncomingMessage.emit (events.js:166:7)
    at endReadableNT (_stream_readable.js:905:12)
    at nextTickCallbackWith2Args (node.js:437:9)
    at process._tickDomainCallback (node.js:392:17)
END RequestId: 754b5cb5-0fb1-11e6-a2ae-ad08cbb0d4ae
REPORT RequestId: 754b5cb5-0fb1-11e6-a2ae-ad08cbb0d4ae   Duration: 783.94 ms   Billed Duration: 800 ms    Memory Size: 128 MB   Max Memory Used: 39 MB   
Process exited before completing request

i deleted the rest of my ID


I haven't set two of the same name. And it can't be because i would see them then in uterances.
4 x Echo Dot, HMLAN Gateway, und diverse HM Komponenten, Philips Hue + OSRAM Plugs

andrejs

If I am honest I do not know exactly what should be wrong. What about if you tested for tv do you get the same error message? I tested again with "configure test event" and take the script index.js and AlexaSill.js from the my post  on 8.12.2015 20:32 (of course I replaced in index.js file APP_ID and urlPrefixurl) uploaded zip file of both js files  to AWS Lamda and the test was sucessful. The test was made for dinning table light and I used the same code for input test event as I gave you in previous post (except I changes the name - the value of litdev). I also have very similar definitions of utterances:

SRset switch {dining table light|litdev} {off|litrea}
SRset switch {dining table light|litdev} {on|litrea} 

and intentschema:

{
  "intents": [
  {
     "intent":"SRset",
     "slots": [
       {
         "name": "litdev",
         "type": "LITERAL"
       },
       {
         "name": "litval",
         "type": "LITERAL"
       },
       {
         "name": "litrea",
         "type": "LITERAL"
       },
       {
         "name": "numdev",
         "type": "NUMBER"
       },
       {
         "name": "numval",
         "type": "NUMBER"
       },
       {
         "name": "numrea",
         "type": "NUMBER"
       }
     ]
  },
  {
     "intent":"SRstater",
     "slots": [
       {
         "name": "litdev",
         "type": "LITERAL"
       },
       {
         "name": "litval",
         "type": "LITERAL"
       },
       {
         "name": "litrea",
         "type": "LITERAL"
       }
     ]
  },
  {
     "intent":"SRgeneral",
     "slots": [
       {
         "name": "litdev",
         "type": "LITERAL"
       },
       {
         "name": "litval",
         "type": "LITERAL"
       },
       {
         "name": "litrea",
         "type": "LITERAL"
       }
     ]
  }
]
}

Andrej

okenny

Hello,

Has anyone tried using the Raspberry pi version of the Echo with this module?
Is this likely to work? I am not sure where to buy a real Echo in Germany

https://www.raspberrypi.org/blog/amazon-echo-homebrew-version/

Thanks!

andrejs

The advantage of Amazon Echo is that you have everything in one device with seven microphones that use enhanced noise cancellation, far-field voice recognition even while playing music or have noise around.
But unfortunately the device is not cheap. If you have opportunity to ask someone to bring the device for USA this would be the best and cheapest solution  (this was in my case).
Otherwise you can only buy Amazon Echo on the Ebay but the price with transportation costs+import duties-VAT is around 200 USD (used) to 250 USD (new) - one example http://www.ebay.de/itm/Amazon-Echo-Personal-Assistant-and-Audio-Streamer-/231960387307?hash=item3601ea9eeb:g:yE4AAOSwdU1W9e3V
The possibility is also to use Borderlinks (http://www.borderlinx.com/brand/buy_amazon-com) to buy directly on Amazon but the transportation costs and duties are not very low (approx. 50 EUR).

Andrej