-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to not send a on command hen send dim command via alexa? #71
Comments
this is what is received when the light is off and A dim command is sent to alexa. So when i dim the light when it was off... it goes to 100 first... then go to the desired dim level ... I have not been able to deal with this issue . msg : Object msg : Object |
You can do it by functions |
Ok that will be project tonigh...lol Do you know a starting point? How to I identify each message in a variable? I do not see anything i can work with to identify ( (i mean discriminate))those two Thanks |
Would be nice if it was passed as a parameter if Alexa was told on/off, Bri or Color. |
Be sure you have 1.9 installed, use debug mode, tell Alexa the 2 commands, look deep in debug window, open sub objects like meta. Good work ) |
I already did, but it is painful to retrieve what I want. I would have to make a function that compares "input object" with "changes object" and "on object". It would be much easier to implement in the code for the node. |
@AZDane If you want to check based on the input command, you can use meta.input attribute. If you want to check only when the state is changed, you can use meta.changes attribute. Check the following example: Alexa, turn off the bedroom light
Alexa, turn off the bedroom light
Notice that after the second "turn off" command "meta.changes" hashmap is empty because the "on" state is not changed and it is still equal to "false". |
Because in my case, Home Assistant and Not Alexa is managing my states. So I can easily have some devices that have a different states than my Alexa think they have. |
Indeed, Alexa's command (input) sent to the hub is stored without any modifications to "meta.input" hashmap. |
Yes, so if I tell Alexa to turn bedroom light on I will get |
Would it not be possible to include the called property using something similar to what node-red-contrib-alexa-home does with the msg.payload.command = "switch|bri|color"
|
"if I tell Alexa to turn bedroom light on I will get You will have changes - Hashmap of all changed attributes and the corresponding old values I believe in your case, it is better to use meta.input, because meta.changes is generated based on the previous state of the object stored in the hub. |
Commands are already included in the payload. Switch command is when you have "on" key in meta.input |
Yes, you are right :) Sorry. it was late when I initially looked at this last night. |
BTW, I don't think it is a good idea to include command attribute in the payload (that's why we don't have it), because you may have multiple state changes if the input payload is sent directly to the hub without using Alexa. Example:
In this particular example, we have switch, dim, and color change commands. |
datech, |
Yep, that's how exactly Alexa is working when "on:false" and brightness is changed. Two separate commands will be sent to the hub:
|
hmmm. ok. Have to rethink how I will handle that one. Doesn't seem very smart in a flow based system like Node-red. Alexa-local only forwarded one, so you only triggered the flow one time. Any recommendations on dealing with two objects? Will the on: true always arrive first? I need to drop the first one if there are two. |
datech, So even if two separate commands are send to the hub, wouldn't it make sense to just forward one combined for the purpose of Node-red? |
I suppose that the logic is that you cannot change the brightness if the device is not turned on. So, I've tested it a few times before, and "on:true" is always the first command. I prefer not to mess up with Alexa's logic. We have the same case when the color is changed, and "on" is set to "false". Alexa will send two commands:
|
Would be nice if there was a way to indicate in the first package that its part of more commands. |
I've just tried Delay node with following options:
|
Yes, but it's the second package thats interesting. I did however figure out how to receive the Bri package first and then drop the second package.
|
really interesting here, I haven't noticed myself Alexa sent 2 messages if she thinks it was off. I would suggest you to create a function and if Alexa incoming message is on you forward it again to the same function by a delay module, adding a flag that is was forwarded. Now if a second message is incoming with bri then you send a reset to the delay node, so the incoming delayed forwarded module will be discarded and never come back. If you receive the forwarded message you will send it as a good one and not to de dealy node. The question is just to set a proper time to the delay that in any case the second message can come after that. I suppose 200ms can be enough to be sure the bri already came. The function can be something like this: (the function should have 2 outputs, on the second connect the input delay node, and connect the output of delay node to the input of the function) `if (msg.meta.bri!==undefined) {msg2= {reset:1}, return [msg,msg2]; //help me to correct it, haven't test it yet, I suppose the meta contains the command, can't find a detailed example in the issue threads forwarded=msg.forwarded || false; |
I consider this issue as resolved. For reference |
Thanks all ! totally works ! [ |
Incomprehensive message from me . Sorry can't delete it
The text was updated successfully, but these errors were encountered: