alisdairjsmyth / node-red-contrib-lifx-api

A collection of Node-RED nodes to control LIFX globes using the HTTP Remote Control API
Apache License 2.0
8 stars 5 forks source link

Cant use variables #12

Closed everything-tech-related closed 5 years ago

everything-tech-related commented 5 years ago

Maybe I'm not using the correct format. I can set power to "on or off" however I cant pass a variable with the intended power state. msg.payload doesn't work.

alisdairjsmyth commented 5 years ago

It is working fine for me. I tested it using the following flow:

image

The function node includes the following:

msg.payload = {
    "selector": "label:Hall Near Door",
    "power": "on"
}
return msg;

If you still can't get it to work, attach a copy of your msg.payload and I will have a look.

everything-tech-related commented 5 years ago

So do you have to manually type "on" in Power section?

alisdairjsmyth commented 5 years ago

All these nodes support static and dynamic behaviour. If you want a node to perform a specific operation on a defined set of globes (eg a node to turn on the power of a specific globe), you can use the Node-Red editor. In this setup, the msg.payload is just the trigger and need not contain any value. However if you have logic in your flow to dynamically set values, you can use msg.payload to send these values to the node.

So do you have to manually type "on" in Power section?

I am interpreting this to mean in the Node-Red editor, and so would be a static definition. The power section supports the values on and off. image

everything-tech-related commented 5 years ago

:) I'm a bit confused with what you just said. Can you make your reply a bit simpler?

Let me try to explain better. I'm sending a voice command to alexa, "turn on bedroom light"

I can see the mag.payloay "on" But how do I get "on" string to paste inside the Power text input? I tried msg.payload...payLoad...nothing works.

I want to use one state node to turn light on or off.

Forgive me if your above answer is correct. I just don't understand it.

everything-tech-related commented 5 years ago
alisdairjsmyth commented 5 years ago

Given you want to use one state node to turn a globe on and off, you need to use msg.payload. To turn it on, you would need to inject a:

msg.payload = {
    "selector": "label:Deveraux",
    "power": "on"
}

and off:

msg.payload = {
    "selector": "label:Deveraux",
    "power": "off"
}

You may need to use a Function node to set msg.payload.

That said, if you want to use Alexa to control your globes there is native support available (see "LIFX Help Center").

everything-tech-related commented 5 years ago

Hi I was able to make it work with a switch node. But I also want to be able to change colors without creating seperate nodes. I have native alexa support for lifx. But I want to use node red to tie everything into a single dashboard. More projects to follow. 15625921729013680445791484534155