Jump to content

Feature request: generic multiplexed devices in ISY portal


apnar

Recommended Posts

Posted

I find one of the greatest additions Amazon did to the smart home section was adding the ability to map a light to a specific echo so you can simply say "Alexa, turn on the lights" and it works in any room.  I'd love to see that functionality expanded, in particular to things like "fan" or "TV" or any number of other words but doubt they'll add too many more.

I'm not an Alexa developer but poked around a bit and believe they added something like an echo device ID to each request sent.  That should let an app know which device a request is coming from.  (If I'm wrong about that of course the rest of this isn't doable)  I envision something like being able to create a generic multiplexed device in the ISY Portal.  Then in the ISY portal being able to configure that generic device to map to a specific real device/scene/etc. based on the specific echo that made the request.  You could also provide for assigning default real device or defaulting to a no-op.

There'd be a little bit of work in populating the list of device IDs originally but I figure any time a request comes in for any generic device the specific echo device ID gets added to the list of known device IDs and is then available for mapping in all generic devices.  You could make it easier to give friendly names to the device IDs by highlighting the last device ID to make a request.  It wouldn't take too long for folks to build up the library of known device IDs.

So as an example I have 2 echos with device IDs AAAA and BBBB.  AAAA is in the family room and BBBB is in the living room.  I create a device in the ISY portal called "fan".  Then in the ISY portal I map any requests for "fan" from AAAA to control the family room fan and any requests coming from BBBB to control the living room fan.

  • Like 1
Posted
On 11/16/2018 at 11:09 AM, apnar said:

I'm not an Alexa developer but poked around a bit and believe they added something like an echo device ID to each request sent.  

Thanks for the suggestion.

Unfortunately, there is no echo device ID or anything else that allows to identify from which echo a request has been made. If you see documentation that says otherwise, please let me know. I looked at the actual payload sent by Amazon when making a request such as turn on/off, and there was nothing that would allow to identify from which echo device a request has been made from.

Benoit

Posted

I don't know whether this helps in this context but you can get the deviceId.  https://developer.amazon.com/docs/smapi/alexa-settings-api-reference.html

Get the API Access Token and Device ID

Each request sent to your skill includes an API access token (apiAccessToken) that encapsulates the permissions granted to your skill. You need to retrieve both this token and the device ID (deviceId) and include them in requests for the customer's settings.

Both the apiAccessToken and device ID deviceId values are nested in the System object, which is nested in the context object. To see the full body of the request, refer to Request Format.

{
  "context": {
    "System": {
      "apiAccessToken": "AxThk...",
      "apiEndpoint": "https://api.amazonalexa.com",
      "device": {
        "deviceId": "string-identifying-the-device",
        "supportedInterfaces": {}
      },
      "application": {
        "applicationId": "string"
      },
      "user": {}
    }
  }
}

Thus:

deviceId = this.event.context.System.device.deviceId

When your code requests customer settings, include:

  • The deviceID in the request path

  • The access token in an Authorization header in the format: Bearer ACCESS_TOKEN, where ACCESS_TOKEN is the value of the apiAccessToken field from the Alexa request message. Here is an example:

Authorization: Bearer AxThk...6fnLok

Thus: accessToken = this.event.context.System.apiAccessToken

See also: Handling Requests Sent by Alexa

 

Posted
On 11/17/2018 at 12:47 PM, bmercier said:

If you see documentation that says otherwise, please let me know.

Thanks @bmercier.  I found what I was looking at a while back and it was the same deviceID field referenced by @nadler above.  I'd seen it in the context of address determination though:

https://developer.amazon.com/docs/custom-skills/device-address-api.html

I'm not sure if you'd have to request for your skill to be able to access address information or not to get the deviceID but deviceID does seem like it'd allow for you to figure out which echo made a specific call.

Posted
@nadler &@apnar, the above documentation applies to Alexa Custom Skill. Smart Home skills don't have that capability. We can't retrieve the deviceId in a smart home skill.


That sucks. Thanks for looking! Hopefully Amazon adds it soon.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...