cakebake / node-red-contrib-alexa-remote-cakebaked

Forked for me and the community to keep dependencies up to date :)
MIT License
42 stars 6 forks source link

How to identify which smart home device - is it possible? #13

Open coppo86 opened 3 years ago

coppo86 commented 3 years ago

Apologies if this is a daft comment,

I have been playing with this functionality and lots of things I have tried work fine. Speech, listing devices, starting skills and routines is all easy enough.

My main use of Alexa and node red is controlling lights and heating using the existing (Hardill based) functionality I can ask Alexa to control lights and heating. The devices are effectively node red devices - Node red is notified of the Alexa command and then drives the appropriate device. The biggest gap is sensible voice feedback to commands and this is where I thought moving to remote2 (now cakebaked) would plug the gap.

I can't get it working though as I have failed to find out how to parse which device Alexa has heard eg I say "Alexa - turn on hall picture rail." The remote event mode sends a message on device activity that includes which Alexa picked up the command. It has the transcription of my command and Alexas reply (if any) what I don't know is how to determine it was the hall picture rail device, without doing my own analyzing *** of the msg text to speech string.

I have tried with all my existing v2 (hardill) devices and also added some new ones for the remote v3. I get notification of all commands but nowhere can i see which device is being commanded.

It could be missing something really simple - hopefully someone has got this to work and can advise me?

(*** Another work around would be to continue using Hardill V2 control and adding remote2/cakebaked in the pot as the voice replies. This seems a long winded way of doing a job though and delays may make it clunky.)

nrout-HA commented 3 years ago

Yes, the device that heard the voice command is in the msg.payload.deviceSerialNumber. You just have to match it with the serial number of the echo devices you have, which can be found in the app or on the device itself. Hope that helps!

coppo86 commented 3 years ago

Thanks. My fault - didnt' make myself very clear! I know how to tell which Alexa heard me. What I don't know how to do is determine which device (lamp in this case) the command referred to.

I have patched together a very cludgy workaround that uses smarthome v3 to manage the devices and send notifications to node red identifying the device needing control. If I need enhanced verbal feedback I use cakebaked to speak a bit more about the event just dealt with wthin node red. I use a timer to make sure cakebaked reports only on the event that has just happened. As I said - its cludgy! I'd like to put all the functionality in one pot.

nrout-HA commented 3 years ago

oh. I guess I still don't understand. If your command is "Turn on hall picture rail," you have multiple hall picture rails and want to be able to specifically address one?

coppo86 commented 3 years ago

I have around 70 or so devices covering heating/lighting/weather and some misc odds and ends. Most are created in Hardill's v2 smarthome bridge system https://alexa-node-red.bm.hardill.me.uk/.

I have three alexas currently. Node red has the V2 bridge endpoint nodes so if I say Alexa turn on hall picture rail, a node in NR picks that up and routes the command to the appropriate 'thing' via its interface (which is one of LWRF/Tasmota/mysensors etc) That all works perfectly and has been running for a year or more.

There are a few gaps in this. Hardill & V2 bridge does not tell me which alexa picked up the command so I don't know where to send any enhanced vocal feedback. I am limited to a few state reporting options in the V2 interface. this is why i cludged the system that uses V2 bridge and cakebaked to give the enhanced voice feedback to the last heard from Alexa. It is messy and also there is no way of determining when Alexa has finished any hard coded response so the enhanced vice is either delayed too long or chops into the hard coded response. It works -sort of.

(I also tried smarthome v3 bridge https://docs.cb-net.co.uk/en/development/ with just 2 or three devices. It also has limitations (neh - bugs). It does not have speech feedback and fell at several hurdles. The logic behind the state reporting seems very random and it didn't cope well with a complex heating system. I have shelved it for now and gone back to V2.)

There has to be one system that would do it all cleanly and I was hoping remote2/cakebaked could do. I can't however find a way of adding a device to remote2 (say a light) OR eavesdropping on a pre-existing device such as those on the V2 bridge. All I can deduce is that the Alexa in the hall picked up a voice command 'Alexa turn on hall picture rail.' I could parse the voice message myself in node red - lots of hard work.

Does that help to see where I am stuck?

Cheers Andy