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

New feature request: setting LED clock brightness #15

Open IanLauder opened 3 years ago

IanLauder commented 3 years ago

Not sure if this is so new an addition to the Alexa devices newest generation where they added the LED clock. I can set the brightness by speaking to the device or using the app. But they don't have it as an option to set it in a routine. So not sure if its available in the API or not?

I'd like to have the ability to set the LED brightness from node-red routines like turning it down to 1 at night and back up to 7 during the day. I can't find any way to automate this yet.

peterchs commented 3 years ago

Are you sure you cant do it in a routine? You should be able to do a customised action and put in what you would normally say to alexa to get the brightness to change. Then its just a case of triggering your routine from nodered. It does have the side effect of alexa saying 'ok' when triggered, and I dont think there is a way to avoid, but it at least gives you an option to automate this.

Note: You are unlikely to get this feature added via an issue here - the core functionality is provided by the library linked below which would need to add support for this first.. (if its needed, see above) https://github.com/Apollon77/alexa-remote

IanLauder commented 3 years ago

I've been searching online as well as having double checked. It doesn't look like Amazon opened that up unless its hidden somewhere. Other threads talking about it have said its not something you can set other than the slider in the app or speaking to the device. There is no routine option I can find yet. Could be its a new enough feature on the new devices its not fleshed out yet. I'll look into custom actions. I haven't ever used that and don't know how that works. Also new enough to using Node Red and the github site I couldn't see where to post comments to the person who seemed to have taken over this node-red code that's now the cakebaked version. Just throwing this out there.

peterchs commented 3 years ago

So you dont have customised action in your alexa app then? What country are you in? Its definitely in UK & US. Top option below when setting up a routine, see screenshot.

image

IanLauder commented 3 years ago

I have it. I just said I've never used that feature before so I'd have to look into how to do something custom like this using it. So far everything I've needed to do with Alexa is just triggering rules in my Hubitat hub or turning on/off a device in the smart home settings. I only resorted to Node Red to set volumes and DND settings across 7 devices more easily by having it pick up a virtual switch being set in the hub then the Node Red flow sets volumes and DND settings across all the devices at night to lower everything then sets them higher again during the day. Not sure if you saw my previous post on this thread about problems I've had with errors in this cakebaked code trying to set the Alarm volume. But since I was here posting that I just threw in this comment about setting the LED brightness as well as that is something I would work into a flow like this. If I can get it working via a custom routine line and have it have to speak out a response that would work, but not quite as clean as I'd like. If I can use a node red node to do the custom routine would be nice. I'll work on it. Not really a priority though.

peterchs commented 3 years ago

Not seen the alarm issue but it may work via a similar workaround. Using a routine with cusomised action is a good workaround when there isnt direct support from the nodered module to do whatever.

IanLauder commented 3 years ago

invalid input: "{"option":"alarmVolume","value":{"device":"G091JJ0910440BRQ","volume":"40"}}"

I use the Alexa Echo node, pick the Alarm Volume, set it to a string 40 and pick one of the echo devices. I get this error showing up in the debug node. I tried googling using that feature and to see if any other posts popped up regarding it or problems and couldn't find anything. I'll give it a shot using your suggestion of custom actions. It may be next week till I have time to dig back into it.

IanLauder commented 3 years ago

I think to use the Custom option in Node Red I have to figure out how to pass in a JSON object? I see the option to select custom in a node but its kind of free form for what you pass in. Haven't experimented with it yet. But I did just resolve the alarm volume problem. It looks like the node-red node code is bugged in that you can only pass in a string value which causes the errors because it needs a number. Trying environment variables that are numbers didn't work neither did the $abs(#) function which should return a number, it just puts a blank value in the input. But, when you use the custom command in an Alexa command it tells you it needs a value from 1 to 10. But in the Node Red code you need to send in a value from 1 to 100. Setting the payload to a number like 50 and passing that in and setting the Alarm Volume to the msg.payload got past the errors and that is working now.

IanLauder commented 3 years ago

If you know how to structure the command in the node red node. I've been trying at it for a couple hours. Online examples are scarse and I've tried a few variations like setting the msg.payload or using the json option but keep getting errors. If you or anyone can tell me how to structure the json or payload string would help. Or point me at some documentation that describes exactly what Alexa is looking for.

payload version: (this gives me Invalid property expression: unexpected ' ' at position 14")

msg.payload={type: "speak", payload: { type: "regular", text: "set clock brightness to 1", devices: "XX91JJ09051603PR"}}

JSON version: (this gives me unexpected token " at position 4)

[ { “id”: “3ff3c45d.20249c”, “type”: “alexa-remote-routine”, “z”: “c8594bdc.1ed9d8”, “name”: “”, “account”: “My Echos”, “routineNode”: { “type”: “speak”, “payload”: { “type”: “regular”, “text”: { “type”: “str”, “value”: “this is a test” }, “devices”: [ “XX91JJ09051603PR” ] } } } ]

JSON version 2: (this gives me unexpected token 2 at position 2)

[{type: "speak", payload: { type: "regular", text: "set clock brightness to 1", devices: "XXF0071863430BD6"}}]

peterchs commented 3 years ago

For the customised action routine workaround you shouldn’t need any Json setup.

  1. Create routine in Alexa app using customised commands to do whatever you want. Test it works in the Alexa app.

  2. In node red flow with an Alexa-remote routine node execute the routine. Should come up in the dropdown.

IanLauder commented 3 years ago

I tried that but I wasn't getting it to work the way I need. I give the verbal commands from another room and the echos with the clocks I want set are in other rooms. Saying something like "set brightness to 1 on bedroom echo" results in errors. Maybe I haven't figured out the exact phrasing yet to do it from another room. I also just wanted to keep all my alexa settings contained in a single node red flow since that was the point of this exercise. I'm trying to add it as a node to this flow.

noderedalexa

IanLauder commented 3 years ago

I'm out of town for a couple days and will pick this up later. I found someone did a Hubitat custom alexa driver I'll look at, maybe with that I can do it, or at least figure out how to automate a custom command that I can move over to this flow. This is just a fun project anyway, not really too important. Thanks for helping.

peterchs commented 3 years ago

For reference the routine I use has customised action with "Alexa, show front door on study echo show" which works ok. Also tested "Alexa, set volume to max on lounge echo dot" and that worked too. If you arent already make sure the 'From' part of the routine as the alexa device you are trying to set? Screenshots below of the routine and node red routine node config.

Failing that maybe the brightness is special and wont work from customised routines :(

image

image
IanLauder commented 3 years ago

I'm familiar with making calls from one device to another including setting up one to talk to another one. Just haven't gotten it to work with the new led brightness on this latest generation. Also, was thinking it through and it wouldn't really work for me as a complete solution to have it issued from an alexa device as a custom command. While I do give a verbal command to an alexa device to activate a routine that sets lights/blinds/heaters/xbox/sonos/etc. when going to bed that would work for lowering the led brightness in the bedroom for example. But we don't give alexa commands on the other direction to turn on the home. That happens via motion sensors, time of day, home vs away modes that trigger Hubitat rules. I have virtual switches that get set in Hubitat that Node Red picks up and that is how I'm kicking off the node red alexa flows and that's how I'd be setting the led brightness back to a daytime level.

peterchs commented 3 years ago

I use the above without talking to Alexa.

In my case I have a motion sensor which when triggered sends an mqtt msg, picked up in node red flow which then notifies me via Alexa talking and then starts the routine with customised action to show the camera view on my echo show.

IanLauder commented 3 years ago

Been trying all sorts of variations on setting the led brightness from a different device, all give "[device name] doesn't support that. Only issuing the command directly to the device is the only thing that works "set brightness to X". Things like set brightness to X on entertainment echo and other variations doesn't work. But I did get it to work by making a routine that uses a timer and then set a custom routine "set brightness to X" from Entertainment Echo.

That means to dim/undim 2 devices at night and morning will take 4 different Alexa routines. Not exactly an elegant or flexible solution that just works with everything else, but its workable for now.