alexa_domo icon indicating copy to clipboard operation
alexa_domo copied to clipboard

Selector switch level names not supported

Open dwmw2 opened this issue 6 years ago • 14 comments

Here's a selector switch as reported by json.htm?type=devices:

      {
         "AddjMulti" : 1.0,
         "AddjMulti2" : 1.0,
         "AddjValue" : 0.0,
         "AddjValue2" : 0.0,
         "BatteryLevel" : 255,
         "CustomImage" : 5,
         "Data" : "Set Level: 100 %",
         "Description" : "",
         "DimmerType" : "none",
         "Favorite" : 0,
         "HardwareID" : 6,
         "HardwareName" : "Onkyo",
         "HardwareType" : "Onkyo AV Receiver (LAN)",
         "HardwareTypeVal" : 104,
         "HaveDimmer" : true,
         "HaveGroupCmd" : true,
         "HaveTimeout" : false,
         "ID" : "00000008",
         "Image" : "Amplifier",
         "IsSubDevice" : false,
         "LastUpdate" : "2018-05-12 06:45:59",
         "Level" : 100,
         "LevelActions" : "Off|10|01|02|05|03|25|24|23|22|2b|29|2e",
         "LevelInt" : 100,
         "LevelNames" : "Off|Bluray|Sky+ HD|Wii|Chromecast|Aux DVI|AM|FM|TV/CD|HDMI cable|NET|USB|BLUETOOTH",
         "LevelOffHidden" : true,
         "MaxDimLevel" : 100,
         "Name" : "Lounge source",
         "Notifications" : "false",
         "PlanID" : "12",
         "PlanIDs" : [ 12 ],
         "Protected" : false,
         "SelectorStyle" : 1,
         "ShowNotifications" : true,
         "SignalLevel" : "-",
         "Status" : "Set Level: 100 %",
         "StrParam1" : "",
         "StrParam2" : "",
         "SubType" : "Selector Switch",
         "SwitchType" : "Selector",
         "SwitchTypeVal" : 18,
         "Timers" : "false",
         "Type" : "Light/Switch",
         "TypeImg" : "Light",
         "Unit" : 0,
         "Used" : 1,
         "UsedByCamera" : false,
         "XOffset" : "691",
         "YOffset" : "257",
         "idx" : "341"
      },

I can tell Alexa, "Set lounge source to 20" and it'll select the Sky+HD box. This is a slightly suboptimal user experience for anyone who doesn't know the levels. Can we make this work with the names from the LevelNames field?

dwmw2 avatar May 12 '18 08:05 dwmw2

https://developer.amazon.com/docs/device-apis/alexa-inputcontroller.html

dwmw2 avatar May 12 '18 08:05 dwmw2

Hi - are you still using alexa-domo, or is this a request for Controlicz? If it's Controlicz, are your selector switches currently detected as Lights or Switches?

madgeni avatar May 12 '18 11:05 madgeni

Alexa recognises my selector switches as "Light/Switch".

Lyr3x avatar May 12 '18 11:05 Lyr3x

The issue with InputController is that it doesn't allow custom names, so alot of your LevelNames wouldn't be recognised - https://forums.developer.amazon.com/questions/79376/inputselect-slot-type.html

madgeni avatar May 12 '18 13:05 madgeni

I am still using alexa-domo. Has the Alexa support in Controlicz moved on? Did anyone get OAuth2 working for Domoticz yet?

dwmw2 avatar May 13 '18 07:05 dwmw2

Ok, i've been looking at this, but the main issue is the Domoticz API. In order to change a Selector Switch level, you call: /json.htm?type=command&param=switchlight&idx=123&switchcmd=Set Level&level=0

In order to handle Level Names, i'll have to do a lookup, which will make an extra call, and slow the request down. Additionally, we're then relying on Alexa understanding your request cleanly enough for me to take that input and then match against your Level Names

madgeni avatar May 13 '18 13:05 madgeni

Alexa-domo is using the deprecated Alexa API, which will be end of life at some stage. Controlicz is running against the latest version, and therefore has access to the latest functionality, as well as controls - for example, Alexa-domo can't use the InputController.

There is no OAUTH2 service in Domoticz, so you still have the same security issue, where I handle the tokens, and have to store (encrypted and hashed) your domoticz details.

madgeni avatar May 13 '18 13:05 madgeni

Is the Controlicz code available? I'm happy to hack in it to make improvements.. and less happy to use something I can't :)

Thanks for all your work on this!

dwmw2 avatar May 13 '18 19:05 dwmw2

Hi - afraid not, i made the decision when Amazon deprecated the last version to offer a service, rather than continue to support the open source version. i'd ended up supporting everyone's lambdas, configs - this way is better for most users (depending on security concerns). You can whitelist the Controlicz IP address.

madgeni avatar May 13 '18 19:05 madgeni

Do you still use Lambda for Controlicz? I can live with the security thing; if I give you a password for the "alexa" user in my Domoticz, that's fairly much equivalent to doing things "properly" with OAuth2. But I have been getting very annoyed with the Lambda first-time spinup recently as we've been adding more devices and using it more, so I was getting very tempted to add support directly into Domoticz itself for being invoked directly: https://developer.amazon.com/docs/custom-skills/host-a-custom-skill-as-a-web-service.html

dwmw2 avatar May 14 '18 14:05 dwmw2

Gr... except I don't think you can host anything except custom skills that way. Of course you ought to be able to host smart home skills on your local network and discover them with uPNP...

dwmw2 avatar May 14 '18 15:05 dwmw2

yep, you can't run the smart home skill that way. Although you might be able to run the Smart Home skill on a lambda, which interacts with the IOT mqtt model, which your domoticz could work with. maybe. I run Controlicz on a server, I handle the alexa interactions on a lambda however. It's tokenised between Alexa and Controlicz, then drops into the https call to your API - so you could whitelist Controlicz, provide a specific Alexa user on your Domoticz, which only has access to those devices you want Controlicz to see.

madgeni avatar May 14 '18 15:05 madgeni

Yeah, I already have a dedicated "Alexa" user. It's calling off-site to lambda that really bothers me, especially the first time. Maybe using yours would be better because I'd only suffer the 20-second Lambda spinup if none of your users have used Alexa in the last ten minutes. Rather than whenever my skill hasn't been used in the last ten minutes.

But still, it really sucks that Alexa won't talk directly to something over the local network. She does for Philips Hue! I'll go file an internal ticket and bitch about that... :)

dwmw2 avatar May 15 '18 07:05 dwmw2

There's no obvious delay, given the nature of the lambda, it's unlikely that the lambda is constantly in action. I'm aware of the spinup issue with lambdas, but i'm not seeing it with Controlicz. I think the Hue is a different case - I think the lights talk to the hub over it's proprietary protocol, but the hub talks to Alexa, which is definitely over the internet.

madgeni avatar May 15 '18 20:05 madgeni