Vera - Smarter Home Control Forum

General => Lighting & Load Control => Topic started by: joek on March 20, 2016, 09:43:38 am

Title: Instructions and Steps to Implement LIFX API
Post by: joek on March 20, 2016, 09:43:38 am
Instructions and Steps to Implement LIFX API - lifx_ctrl()

The LUA code lifx_ctrl() provides ability to control LIFX lights via Vera U15 and U17. The implementation uses the LIFX API (RESTful) and therefore an internet connection is required for network access to LIFX servers. The LIFX control provides a basic framework so can easily be modified to enhance its functionality. It's implemented as a LUA function and the function can be called by other LUA code or from LUUP within a scene on the Vera.



INSTALLATION

LIFX API Access TokenJSON Support on Vera U15 and U17
Install lifx_ctrl.lua (code is in attachment below)


USAGE

Use the following link to get all the LIFX API parameters: http://api.developer.lifx.com/docs/ (http://api.developer.lifx.com/docs/) The lifx_ctrl function can be used inside a Vera scene luup (or from another luup code) as follows:

   stat, pwr, conn, err, resp = lifx_ctrl (selector, mode, color, bright, cycles, period)

  where:
     selector - choose "all", group or a specific LIFX light
     mode - on, off, toggle, pulse, breathe or list
     color - red, green, blue, pink, etc.  or  #RRGGBB format
     bright - brightness setting (0.0 - 1.0) for "on" and "pulse" modes
     cycles - no. of cycles to pulse the LIFX light(s) when in "pulse" mode
     period - time in seconds for one cycles of the effect


  return values:
     stat - status of LIFX API command
     pwr - power state of LIFX light
     conn - LIFX light is connected to WiFi
     err - error message if one exists
     resp - string containing entire response from LIFX API command

  * Note: lifx_ctrl() LUA code puts an entry into LuaUPnP.log Vera log file after it executes.



Some example usage:
lifx_ctrl("id:f055d5005dde", "pulse", "blue",.5, 5, 2) -- pulse bulb blue 5 times at 1/2 brightness & cycle period of 2 secs
lifx_ctrl("all", "on", "#00ff00", 1) -- turn on all lights green at full brightness
lifx_ctrl("all", "off") -- turn off all lights
lifx_ctrl("all", "toggle") -- toggle all lights
lifx_ctrl("id:f055d5005dde", "off") -- turn off selected light
lifx_ctrl("label:bulb01", "breathe", "yellow",1, 3,.5) -- breathe blub yellow 3 times at full brightness & cycle period of .5 secs
lifx_ctrl ("label:bulb01" , "breathe" , "white" , 1 , 2 , .04) -- a lightning effect


Example luup code used inside a Vera Scene:
function delaylifx()
  lifx_ctrl("label:bulb01", "toggle") -- toggle lifx
end

luup.call_delay('delaylifx', 1) -- Call function after a delay of 1 seconds


Enjoy!!!



UPDATES
10/01/16 -
      - changed instructions to support U15 and U17 releases
      - rename json.lua to myjson.lua for U17 support
      - added "period" parameter to lifx_ctrl()
      - added "breathe" mode to lifx_ctrl
      - updated instructions and examples

03/25/16 - added brightness parameter for pulse mode - thx to @ilikelife

LiFi Labs if you are listening, please change the behavior of the LIFX bulbs after power interruption. Having an option to return to previous state as opposed to white at full brightness would be useful.  It would also give LIFX an edge over your major competitors since they all do the same by turning on white at full brightness.  It prevents me and others from using the bulbs throughout the house because power interruptions are common enough.
Title: Re: Instructions and Steps to Implement LIFX API w/ Vera U15
Post by: jsingle on March 21, 2016, 12:28:42 am
Joek,

Thank you for taking the time to document and post this.  Do you foresee any issues with this process and UI7? 

I'm using VeraPlus.  I'll give it a go in a few days, but after two resets of the VeraPlus and two full network rebuilds (inclusion and all), I want to make sure the core network is stable before attempting anything new.
Title: Re: Instructions and Steps to Implement LIFX API w/ Vera U15
Post by: joek on March 21, 2016, 11:33:09 am
@jsingle

The lifx_ctrl lua code is very basic/simple and would not expect any difficulties, but I did not test on U17 since I am not running that version.  Please report back when you have it running on U17.

Regards,
Joe
Title: Re: Instructions and Steps to Implement LIFX API w/ Vera U15
Post by: ilikelife on March 22, 2016, 03:19:36 pm
Hi @joek,

I can report some progress on UI7, but because of my lack of knowledge, I'm not sure where I've screwed up.

First, I believe think there is a typo in the line to add to startup lua.  Shouldn't it be require("lifx_ctrl.lua") instead of ctrl_lifx.lua?

Instructions and Steps to Implement LIFX API w/ Vera U15 - lifx_ctrl()
   
  • Install lifx_ctrl.lua (see attachment below)
    • Make sure your private LIFX API token is added to lifx_ctrl.lua code, then
    • Copy lifx_ctrl.lua to Vera using U15 GUI.  APPS → Develop APPS → Luup files.  Make sure to check the button "restart Luup after upload"
    • Add 'require("ctrl_lifx.lua")'  to Vera startup lua:   APPS → Develop APPS → Edit Startup Lua

By just doing those 3 steps we were able to get "all" or selected lights to turn off or toggle, but could not get the "on" command to work.  (The friend who owns these bulbs has only "monochrome" bulbs, not color, so we were not able to check the color command.)  We were not able to get "pulse" to work trying  lifx_ctrl("id:xxx", "pulse", NULL, .5, 5)

Quote
  • JSON Support on Vera U15
    • Download the json lib from: https://gist.github.com/tylerneylon/59f4bcf316be525b30ab (https://gist.github.com/tylerneylon/59f4bcf316be525b30ab)
    • Copy the downloaded file "json.lua" to the Vera by using scp (secure copy) to the "/etc/cmh-ludl/" directory.  Do not use the U15 GUI to copy the file because it automatically compresses the file and won't work.
    • Example command:  scp json.lua  root@veralite:/etc/cmh-ludl/

Because your instructions say this is to add json support to UI5, we did NOT load the json lib in Vera and as a result did get an error at line 68 in your lua.
Quote
[string "--[[..."]:68: attempt to call field 'parse' (a nil value)

I just don't know enough to be comfortable copying that version of json lib to Vera running UI7.  Any thoughts/suggestions you or others can offer on how to proceed from here would be appreciated.

(My friend was VERY pleased to get this far!)

Thanks,

EDIT:  We did get "on" working by adding a value in the color parm so  lifx_ctrl("all", "on", "#ffffff", 1, NULL) works
Still have the error because it can't find the parse command, but that is expected
Title: Re: Instructions and Steps to Implement LIFX API w/ Vera U15
Post by: joek on March 22, 2016, 09:17:55 pm
@ilikelife

Glad you made some progress.  Fixed the typo - thanks for pointing that out.

I only have color LIFX lights, so not able to test monochrome bulbs. Did you try "#ffffff" for the pulse color value?  You could also go to the bottom of the following website and try different values for the monochrome bulb and let me what works: http://api.developer.lifx.com/docs/pulse-effect (http://api.developer.lifx.com/docs/pulse-effect)

Also, you can find your bulbs id from the bottom of this webpage: http://api.developer.lifx.com/docs/list-lights (http://api.developer.lifx.com/docs/list-lights)  Put all in the selection box.

U17 includes a json lua lib where U15 doesn't - which is the reason to have to copy one to the Vera.  If there isn't another json.lua file in U17 then should be okay to copy the file to the Vera.  Or, if you really don't care about the return values from lifx_ctrl.lua, then you could just delete lines 24 and 68-89 in the code. Those lines are just parsing the json results from the LIFX API and returning the values.

Thanks for the feedback!

Regards,
Joe
Title: Re: Instructions and Steps to Implement LIFX API w/ Vera U15
Post by: ilikelife on March 22, 2016, 11:49:40 pm
@joek,

Yes, pulse works with "#ffffff" and "kelvin:2500" (to 9000) works as the color value in the "on" example.  So everything does work on UI7

There is already a json.lua so I'm still reluctant to put that in.  For now we've commented out the return values section, but will play more to see what we can come up with.

Thanks again for building and documenting this!

Mike
Title: Re: Instructions and Steps to Implement LIFX API
Post by: majorcuddles on March 25, 2016, 11:15:19 am
Hey guys... I just wanted to say thanks for your efforts here... :)

I love my (22) Lifx's but was getting frustrated at lack of straightforward integration...

Please let me know if y'all need additional testers: I have Lifx Original, Lifx White 800, & Lifx Color 1000 bulbs.

Currently running Vera Lite on UI5 with a Vera Plus enroute.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: mpalensh on May 14, 2016, 03:26:14 pm
Is it possible to pass the ID of a LIFX Group, instead of an individual bulb?  I've been trying, but no luck so far.  Thanks so much for this - I've been really disappointed that I couldn't properly integrate my LIFX bulbs with my Vera scenes.

Now, if I could only get them to consistently stay on the WiFi network!  One problem at a time, though.

EDIT:  Figured it out - I had to pass the name, and not the ID.

For anyone else, here's a sample group off command to add to the examples above:

lifx_ctrl("group:Great Room", "off") -- turn off selected group

Title: Re: Instructions and Steps to Implement LIFX API
Post by: Systmworks on June 01, 2016, 05:21:07 am
Thanks joek for sharing this excellent way of controlling our LIFX lights from Vera.

The script is working fine for me - the only odd thing I notice is when I try testing a command in "APPS → Develop APPS → Test Luup code (Lua)"   the command successfully does what its supposed to  (turn a light on, off, etc), but I get a "Code failed" popup box every time.    It looks like a Vera dialog box, with green OK button to close.   Is this normal ?
Title: Re: Instructions and Steps to Implement LIFX API
Post by: joek on June 07, 2016, 07:47:43 am
Thanks joek for sharing this excellent way of controlling our LIFX lights from Vera.

The script is working fine for me - the only odd thing I notice is when I try testing a command in "APPS → Develop APPS → Test Luup code (Lua)"   the command successfully does what its supposed to  (turn a light on, off, etc), but I get a "Code failed" popup box every time.    It looks like a Vera dialog box, with green OK button to close.   Is this normal ?

I am guessing perhaps it may have to do with parsing the json response in the code. May want to verify the json.lua file is installed on your Vera.  Are you using U15 or U17?  For U17 I recommend changing the json.lua filename to something like myjson.lua because U17 already has a file named json.lua - U15 does not.  I will update code and instructions soon.

I find ALTUI to be much more helpful when testing lua code because you can see error messages, return values and print output.

Joe
Title: Re: Instructions and Steps to Implement LIFX API
Post by: JasonJoel on June 15, 2016, 11:26:25 am
Has anyone actually done this with UI7? I will be mainly controlling the LIFX via my Harmony remote but I would like on off capability from Vera as well.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Systmworks on June 19, 2016, 02:10:09 am
Thanks for your reply joek.

I am using the VeraEdge (UI7).   Your script works great as-is, its only the test code part (works) but cause an error message, so its no biggie.

@JasonJoel - yes this script is working for me on UI7.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: joek on June 21, 2016, 09:58:11 am
Has anyone actually done this with UI7? I will be mainly controlling the LIFX via my Harmony remote but I would like on off capability from Vera as well.

Yes script works fine with U17 - I've since upgraded to VeraPlus (U17).  I'd recommend changing the json.lua filename to something like myjson.lua because U17 already has a file named json.lua - U15 does not.  Obviously, the lifx_ctrl.lua code would also have to reflect the file name change.  :-)

I will update code and instructions soon. 
Title: Re: Instructions and Steps to Implement LIFX API
Post by: mcblah on July 15, 2016, 01:16:01 pm
Just an FYI if you havent "claimed" your bulbs in the mobile app then the api won't work as the bulbs won't be connected to the cloud. I overlooked this as they were working from the app and didnt notice the option to claim them when you select the individual bulb.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: stibbzy on July 15, 2016, 08:09:24 pm
Hello,

Since updating to the latest vera firmware version 1.7.830, your wonderful lifx service has stopped working for me. It was working very well prior to the upgrade. Now, whenever I attempt to use it in a scene, I get this error in the logs:
Quote
50   07/16/16 10:02:59.464   luup_log:0: lifx: {"results":[{"id":"d073d503a71f","label":"Main Bed Light","status":"offline"}]} <0x2fc45680>
08   07/16/16 10:03:02.158   JobHandler_LuaUPnP::HandleActionRequest device: 0 service: urn:micasaverde-com:serviceId:HomeAutomationGateway1 action: RunScene <0x2fc45680>
08   07/16/16 10:03:02.159   JobHandler_LuaUPnP::HandleActionRequest argument serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1 <0x2fc45680>
08   07/16/16 10:03:02.159   JobHandler_LuaUPnP::HandleActionRequest argument action=RunScene <0x2fc45680>
08   07/16/16 10:03:02.160   JobHandler_LuaUPnP::HandleActionRequest argument SceneNum=81 <0x2fc45680>
08   07/16/16 10:03:02.161   Scene::RunScene running 81 Toggle LIFX Lights <0x2fc45680>
50   07/16/16 10:03:02.612   luup_log:0: lifx: {"results":[{"id":"d073d503a71f","label":"Main Bed Light","status":"offline"}]} <0x2fc45680>

I've double checked the entry in startup lua, and done a few lua restarts and vera reboots. Note that the bulb is still completely controllable with the Lifx app. Am I doing anything wrong?

Thanks, Mark.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: stibbzy on July 16, 2016, 01:28:05 am
Hmm, it's now started working again... Is it possible that the cloud service wasn't woking, and that is why my Lifx app would work on my local network?
Title: Re: Instructions and Steps to Implement LIFX API
Post by: joek on July 17, 2016, 03:00:50 am
Hmm, it's now started working again... Is it possible that the cloud service wasn't woking, and that is why my Lifx app would work on my local network?

Based on your log entry the lifx bulb may have been offline: 

50   07/16/16 10:02:59.464   luup_log:0: lifx: {"results":[{"id":"d073d503a71f","label":"Main Bed Light","status":"offline"}]} <0x2fc45680>

Glad is working again.

Joe
Title: Re: Instructions and Steps to Implement LIFX API
Post by: stibbzy on July 17, 2016, 05:36:27 am
yeah it seems like the cloud service was offline. I was able to use the Lifx app locally.

Anyway, thanks so much for the plugin!
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on July 18, 2016, 01:19:45 am
This sounds like a great feature, but I'm a little hesitant to set up anything that relies fully on the cloud.
What are the main reasons why this plugin cannot be modified to work over the LAN when required?
I could see that as being very frustrating if you have temporary ISP issues and cannot turn on your lights to find your way to the bathroom at night (for example).

Thanks for putting this together, as well as for helping me understand this limitation.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: joek on July 23, 2016, 12:12:48 pm
This sounds like a great feature, but I'm a little hesitant to set up anything that relies fully on the cloud.
What are the main reasons why this plugin cannot be modified to work over the LAN when required?
I could see that as being very frustrating if you have temporary ISP issues and cannot turn on your lights to find your way to the bathroom at night (for example).

Thanks for putting this together, as well as for helping me understand this limitation.

Local LAN access to LIFX is possible via their LAN Protocol: https://lan.developer.lifx.com/docs  However, I if recall correctly it requires a local server.  There are folks that created python libs for LIFX that use local LAN, but still requires a local server to operate.

Using the LIFX HTTP API was easy to implement, but you are correct that it requires internet access to their servers per their API.

Joe
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on July 26, 2016, 02:08:33 am
Local LAN access to LIFX is possible via their LAN Protocol: https://lan.developer.lifx.com/docs  However, I if recall correctly it requires a local server.  There are folks that created python libs for LIFX that use local LAN, but still requires a local server to operate.

Using the LIFX HTTP API was easy to implement, but you are correct that it requires internet access to their servers per their API.

Joe

I'm probably part of a small minority, but it rubs me the wrong way that I'm at my ISP's mercy when it comes to controlling my lights. I thought one of the main purposes of the Vera was to act as a "server" for these simple automation tasks?
Thanks for your reply!

-Derek
Title: Re: Instructions and Steps to Implement LIFX API
Post by: stibbzy on July 26, 2016, 05:15:31 am
That is Vera's purpose, but this is an issue around Lifx's APIs, and interacting with those APIs doesn't just happen. Someone has to take the time to write an appropriate plugin for the Lifx LAN protocol and be happy with running a local 24 hour server if they want to integrate it into Vera. Depending on how skilled one is writing the plugin, it may be able to use the Vera itself as the server if the plugin can be written that way...

I've found joek's HTTP implementation stable and very useful so far.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on September 02, 2016, 01:28:18 am
Hey JoeK,
I bought a bunch of these bulbs, dug up my old Vera 2 (with UI5) and tried out your plug-in.

I'm getting a real kick out of this and I just wanted to say thanks for making this available for us. It's pretty cool!

All the best!

-D
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on September 05, 2016, 01:16:39 am
One thing I can't get to work and I'm wondering if it's just not programmed into the plugin --
I've been trying to use "label:name, label:name 2, label:name 3" instead of individual ids, as instructed here: https://api.developer.lifx.com/v1/docs/selectors
Am I doing something wrong, or it's just not available?

Also, any chance we can get the "breathe" function as well?

Thanks
Title: Re: Instructions and Steps to Implement LIFX API
Post by: joek on September 08, 2016, 03:01:51 pm
One thing I can't get to work and I'm wondering if it's just not programmed into the plugin --
I've been trying to use "label:name, label:name 2, label:name 3" instead of individual ids, as instructed here: https://api.developer.lifx.com/v1/docs/selectors
Am I doing something wrong, or it's just not available?

Works for me using the following syntax for example:   

                    lifx_ctrl("label:Bulb01,label:Bulb02", "on","blue",.2)

Quote

Also, any chance we can get the "breathe" function as well?

Thanks

Been very busy on other things but will add "breathe" next code update.

Thanks,
Joe
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on September 08, 2016, 04:55:01 pm
Thanks. I understand how the projects can start to pile up! I appreciate your work and even as the plugin stands it's super useful. I now have it set up to flash my lights when the doorbell is pressed by pairing its functionality with my Elk alarm system and related plugin. The only reason I'm requesting the "Breathe" function is because I find the Pulse a little jarring. I wouldn't want a guest having a seizure because the doorbell rings.  ;)

I figured out the error with my syntax while trying to use "label". It was actually just a silly mistake of forgetting that the label names are case-sensitive.

Is there currently a command to activate a scene, or is that something else that you would need to invest time into? If it's already implemented, what is the syntax?

Thanks!

-D
Title: Re: Instructions and Steps to Implement LIFX API
Post by: joek on September 08, 2016, 05:06:37 pm

Is there currently a command to activate a scene, or is that something else that you would need to invest time into? If it's already implemented, what is the syntax?


It's not in the code but also not difficult to add it in because the framework is there already.  Hope to work on it this upcoming weekend.

Cheers!

10/1/16 update:

    Added the breathe per your request. Will add the feature to activate a LIFX scene in the next update. New code and updated instructions are in the opening message on page 1.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: joek on October 01, 2016, 03:05:32 pm
New code with added features - http://forum.micasaverde.com/index.php/topic,36961.msg275597.html#msg275597

UPDATES:

10/01/16 -
      - changed instructions to support U15 and U17 releases
      - rename json.lua to myjson.lua for U17 support
      - added "period" parameter to lifx_ctrl()
      - added "breathe" mode to lifx_ctrl
      - updated instructions and examples

Enjoy!
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on October 01, 2016, 04:16:33 pm
Thanks Joe!
That's awesome! I'm looking forward to working this feature into my setup, but I'm currently experiencing a major setback with my bulbs. I made changes to my network settings and reset my LIFX app to re-onboard the bulbs, but they wouldn't connect to my router. After returning the settings to their original state the bulbs still won't onboard.
Hopefully an app update is released soon that fixes my issue. So far support has been helpful, but ultimately unable to resolve the issue.
I think it may be something to do with the Android (6.0.1) app.

Thanks again in any case.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Hippogriff on October 05, 2016, 06:43:40 am
I enjoyed reading this thread and I like the function provided here. I took the Python from the LIFX pages and wrote up some Lua for the individual things I wanted my 1 LIFX Bulb to do... basically, turn on at a random colour and turn off, so 2 little bits of Lua. I am writing here to put myself in the good company of others who think the LIFX Cloud is a bit of overkill for most of us - I would also relish being able to just write a bit of Lua that could tell my LIFX bulb what to do locally (on the same network). As my LIFX Bulb is controlled by a PIR I find it can be somewhat unresponsive (by that I just mean there's a delay) when the Scene is triggered... I think that would go with local control as I put the delay down to communication with LIFX Cloud.

Still - a good thread and a nice bit of Lua.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on October 21, 2016, 03:24:40 pm
Hey Joe,
I've run into some problems with my bulbs and have since been unable to use them, but I was still wondering if you've considered building your code into a full-fledged Vera plugin. That would be pretty sweet!
I've been looking at the RGB plugin a little, about to add a Fibaro RGBW controller and I'm thinking it would be pretty kick-ass if there were a quick and easy way to coordinate the devices if I ever manage to setup LIFX bulbs again.

-Derek
Title: Re: Instructions and Steps to Implement LIFX API
Post by: joek on October 21, 2016, 03:36:11 pm
Hey Joe,
I've run into some problems with my bulbs and have since been unable to use them, but I was still wondering if you've considered building your code into a full-fledged Vera plugin. That would be pretty sweet!
I've been looking at the RGB plugin a little, about to add a Fibaro RGBW controller and I'm thinking it would be pretty kick-ass if there were a quick and easy way to coordinate the devices if I ever manage to setup LIFX bulbs again.

-Derek
@Quixote

Sorry, no intentions for me to build a LIFX plugin. IMO, it would be best for LiFi Labs to develop and support an official LIFX plugin for Vera.

Regards,
Joe
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on October 21, 2016, 03:37:12 pm
Bummer.  We both know that will never happen.   :(
Title: Re: Instructions and Steps to Implement LIFX API
Post by: jcposada on November 07, 2016, 01:36:42 am
Just wanted to say thanks for doing this work and publishing so others can benefit from it. I was able to easily get my scenario working (turn on a specific set of lights for a specific period of time when a specific code is entered on a lock).

JC
Title: Re: Instructions and Steps to Implement LIFX API
Post by: magispat on November 09, 2016, 02:07:18 pm
from a home automation newbie, just wanted to say thanks!  just to be slightly difficult, has anybody managed to get the fade on / off duration working?
Title: Re: Instructions and Steps to Implement LIFX API
Post by: majorcuddles on November 24, 2016, 01:07:09 pm
Thanks again for your contributions to the community


Sent from my iPhone using Tapatalk
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on December 04, 2016, 09:57:09 am
Hi Joe,
I just tested my Lifx bulbs again this morning and I guess they must've fixed something because they actually worked this time I tried to connect to them with the app. :)
I set them up on my new Vera Plus and started doing a little testing with the new breathe function and I'm finding some strange behavior. I'm having my bulbs retain the color that I choose for the breathe rather than return to their original color as they were with the pulse function.
Has anyone else noticed this with their setup?
Thanks.

-D
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on December 10, 2016, 12:40:35 pm
Can someone please test the breathe function and verify my results?
Title: Re: Instructions and Steps to Implement LIFX API
Post by: joek on December 17, 2016, 08:03:30 am
@Quixote

Sorry I am not at a place where I can test the breathe function, but did check the Lua code. The code does have the presist set to false, which should retain the color prior to starting breathe.

You could test the lifx api yourself by going to their web page and using the breathe function. The link is in the first post.

Joe
Title: Re: Instructions and Steps to Implement LIFX API
Post by: silfa718 on January 04, 2017, 12:32:35 am
Just got this working, and everything worked on the first try. Thanks for the clear instructions.

Would it be possible to to add duration (How long in seconds you want the power action to take.) to the parameter list. At first I thought this the period parameter.

Also if i wanted to create a dimmer scene, that would look at the current brightness and raise (or lower) by a factor of .1 from the current state, would that be possible? How?
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on January 05, 2017, 06:48:37 am
Also if i wanted to create a dimmer scene, that would look at the current brightness and raise (or lower) by a factor of .1 from the current state, would that be possible? How?

To be honest, I don't really know what I'm doing, but I used to do some scripting in Lua years ago. If you know Lua, then I think what you would want to do is define a global variable for the level of that light in your "Startup Lua" (under apps, develop apps - where you had to enter require("lifx_ctrl.lua") ), using a value of between 0.0 and 1.0. I think you could write code to query the light for its level, but that functionality is not built into the script in its present state as far as I know.
You would then modify that variable at the time that you control the bulb to reflect its state.
After that, you could create a scene that adds or deducts 0.1 to/from that variable, redefines the variable with that new value and replaces the defined level with your variable.
I hope I'm explaining myself clearly here. Keep in mind that the minute you use another method to control the bulbs (like the app, for instance), the system will break until you control the bulb(s) with your scenes again which would then redefine the variable(s).

Joe,  I did some testing and it was indeed the Vera that was misbehaving. The test through the website worked fine. I managed to fix it though. I believe what happened was that I lost the LIFX files when support messed around with my firmware during a remote session, so I had to copy the files back over and I must've copied an old file over or something. Once I re-did the whole install process from scratch, everything worked perfectly. Thanks for looking into that in any case.

I was wondering how difficult it would be to add the ability to execute scenes. One reason this would be great is because the LIFX developers seem to be having difficulty with the idea of having groups in child/parent relationships. As a result, I've had to create many different scenes as a workaround. While I could go and program each one manually, it sure would be a time saver if I could just use a line from your script to call up scenes instead. I've also created many scenes to emulate the colors of a sunrise, etc. and it would be painstaking work to have to go in and figure out the hex value for each and every light for each of those scenes.

Last question for this post -- I know that the values for the light levels are between 0.0 and 1.0, but does that mean that we're restricted to level changes of 10%, or can we use a value like 0.57, for example?

Thanks!
Title: Re: Instructions and Steps to Implement LIFX API
Post by: silfa718 on January 05, 2017, 11:45:59 am

To be honest, I don't really know what I'm doing, but I used to do some scripting in Lua years ago. If you know Lua, then I think what you would want to do is define a global variable for the level of that light in your "Startup Lua" (under apps, develop apps - where you had to enter require("lifx_ctrl.lua") ), using a value of between 0.0 and 1.0. I think you could write code to query the light for its level, but that functionality is not built into the script in its present state as far as I know.
You would then modify that variable at the time that you control the bulb to reflect its state.
After that, you could create a scene that adds or deducts 0.1 to/from that variable, redefines the variable with that new value and replaces the defined level with your variable.
I hope I'm explaining myself clearly here. Keep in mind that the minute you use another method to control the bulbs (like the app, for instance), the system will break until you control the bulb(s) with your scenes again which would then redefine the variable(s).


This is my first experince with Lua.
Thanks for the suggestions, but the fact that other scenes changes or app changes would break this method won't work.

A little background into what I'm trying to accomplish:
I have a Lutron Pico remote that works controlling the LIFx light with buttons for ON, OFF, Dim light to 75%, Dim light to 25%, and random color pick.
I created a scene for each action and assigned the scene to the remote buttons.
This works great, I can control the light brightness, colors, and toggle ON/OFF. ON resets to default color.
I want to improve the dim up/down feature. Right now the scene's LUA code just says to set the light to either 75 or 25. What I would like the scene to do is read the current light brightness and increase/decease by an increment amount. 

I don't know if you could pass a variable as the brightness value.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on January 05, 2017, 03:20:31 pm
This is my first experince with Lua.
Thanks for the suggestions, but the fact that other scenes changes or app changes would break this method won't work.

A little background into what I'm trying to accomplish:
I have a Lutron Pico remote that works controlling the LIFx light with buttons for ON, OFF, Dim light to 75%, Dim light to 25%, and random color pick.
I created a scene for each action and assigned the scene to the remote buttons.
This works great, I can control the light brightness, colors, and toggle ON/OFF. ON resets to default color.
I want to improve the dim up/down feature. Right now the scene's LUA code just says to set the light to either 75 or 25. What I would like the scene to do is read the current light brightness and increase/decease by an increment amount. 

I don't know if you could pass a variable as the brightness value.

No, other Vera scene changes would not disrupt this method since you would modify the variable(s) with each light level change. If you use the app on your phone though, you would have no way of changing those variables to mirror the states of the lights and would thereby break that system. I think the confusion we're having about "scenes" is that both the Vera and the LIFX app use the term "scene". If you use the LIFX app to apply a (LIFX) scene, then it's obviously not going to communicate with the Vera.

I understand what you're trying to accomplish. I'm not familiar with the Lutron Pico remote, but it sounds like you're working strictly through the Vera, so it seems that the method I mentioned may not be so bad (not to mention your only option ;) ).
I don't see why you wouldn't be able to pass a variable as the brightness value as long as the syntax is correct. Sorry, it's been many years since my Lua days, and I'm afraid I've forgotten most of it, but I'm sure there is someone here that is far more knowledgeable that can help.

The problems we would have with the way things are set up now as I understand them are that 1) I'm not sure if we can use the script to find the level of the light. The first post states that the "return values" include "pwr - power state of LIFX light", which could be the level of the light or maybe just on/off (?). We'll need to wait for Joek to shed some light on that and how to use the return values. 2) The level used to instruct the bulbs is an absolute value ranging from 0.0 to 1.0. There is no command for incremental modifications to brightness, so any way you look at it, I think you're going to have to learn a little Lua and write a very basic script using the method that I outlined earlier.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: joek on January 05, 2017, 06:05:06 pm
Unfortunately, I don't have access to my LIFX bulbs at the moment, but believe the 'list' mode provides all current settings of your bulbs (to include brightness).  You'd have to parse the return value to determine the current brightness level.

I did implement the 'list' mode in lifx_ctrl.lua so should receive the return values.  More info here on lifx API: https://api.developer.lifx.com/docs/list-lights

Cheers!

Joe
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on January 05, 2017, 06:18:07 pm
Unfortunately, I don't have access to my LIFX bulbs at the moment, but believe the 'list' mode provides all current settings of your bulbs (to include brightness).  You'd have to parse the return value to determine the current brightness level.

I did implement the 'list' mode in lifx_ctrl.lua so should receive the return values.  More info here on lifx API: https://api.developer.lifx.com/docs/list-lights

Thanks for the reply. Can you clue us in on the syntax we would use with your script and how the return values are handled? Do they populate a table somewhere or is it just one variable with one long string?

Edit: Also, did you notice my post a few posts back? I had a couple of questions I mentioned there that you won't need access to your bulbs in order to advise me. Thanks again.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: silfa718 on January 06, 2017, 12:16:32 pm
Thanks for the reply. Can you clue us in on the syntax we would use with your script and how the return values are handled? Do they populate a table somewhere or is it just one variable with one long string?


After this get answered, I guess I'll have to get busy figuring out LUA

Thanks for the help
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on January 06, 2017, 01:47:16 pm
Thanks for the reply. Can you clue us in on the syntax we would use with your script and how the return values are handled? Do they populate a table somewhere or is it just one variable with one long string?


After this get answered, I guess I'll have to get busy figuring out LUA

Thanks for the help

No problem at all. It's actually a pretty good idea and if I weren't using the Android app, I'd probably do the same thing. I'm a little preoccupied right now, but maybe I'll see if I can remember some Lua from about a decade ago. :)
You can find the manual online in PDF format.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on January 14, 2017, 08:46:36 pm
Joe, you MIA?
 :-\
Title: Re: Instructions and Steps to Implement LIFX API
Post by: silfa718 on January 15, 2017, 01:21:06 pm
My vera no longer shows my lifx lights anymore in the dashboard, happen to anyone else? It was working as of a couple days ago.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on January 15, 2017, 01:30:08 pm
I never had my lights showing on my dashboard. Only the scenes I created with the scripts.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: silfa718 on January 15, 2017, 01:41:05 pm
I never had my lights showing on my dashboard. Only the scenes I created with the scripts.

Okay, I forgot how this worked, I'll test it and check back later

Update:

Found my problem. My bulb wasn't connecting to the LIFX cloud. Why or how I don't know. I reset the bulb via the app and it is working again.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: leyton01 on January 23, 2017, 10:05:32 am
Joe,

Would you consider modifying this to run the LIFX LAN API instead? Eliminates cloud/internet issues and should make it quicker and more reliable.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on February 10, 2017, 07:21:57 am
Well, it seems that Joe has deserted us.
I got impatient, so I opened the lifx_ctrl.lua file to poke around a little and try to figure out one of the features I needed. I finally managed to make sense of that particular problem, and it seems that the feature was actually already programmed into the script and it was only a matter of finding the syntax.
For anyone interested in activating the scenes that you've created using the LIFX app, you can go to this page:
https://api.developer.lifx.com/docs/list-scenes
Enter the token that you plugged into your lifx_ctrl.lua file and hit "Try it!" and you'll get a list of your scenes. From there, you find the scene "uuid" (looks like a serial number), listed in the line right above the name of the scene.
In your newly created scene on the Vera, use the Lua code:

lifx_ctrl("scene_id:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "scene")

replace the "xxxx"s with your scene uuid. Simple as that.
Enjoy.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on February 15, 2017, 02:31:38 pm
Is there anyone here that is knowledgeable enough in Lua to modify the lifx_ctrl.lua file to allow us to specify the duration for the scene function?
I'd like to set up my sunrise and sunset scripts to change color over several minutes, but I'm not sure how to modify the control script. It doesn't look that complicated for someone that knows what they're doing.
Thanks in advance.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: joek on February 25, 2017, 08:00:27 am
Joe,

Would you consider modifying this to run the LIFX LAN API instead? Eliminates cloud/internet issues and should make it quicker and more reliable.

I've looked into operating the Lifx bulbs via local LAN some time ago, but determined using the lifx Rest API would be easier to implement. Plus not certain how to implement Lan portion on the vera, so would have to run a local server.

Joe
Title: Re: Instructions and Steps to Implement LIFX API
Post by: joek on February 25, 2017, 08:05:52 am
Well, it seems that Joe has deserted us.

That's not true I've not deserted this thread.

I subscribe to this thread and for some reason I am no longer receiving notifications when a new message is posted. I just reset my notifications so hopefully that fixes it.

Joe
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on February 25, 2017, 04:54:41 pm
Well, it seems that Joe has deserted us.

That's not true I've not deserted this thread. That's fake news!

I subscribe to this thread and for some reason I am no longer receiving notifications when a new message is posted. I just reset my notifications so hopefully that fixes it.

Joe

XD  Well, I figured that fake news was all the rage these days, so I'd get in on the action. Sorry, I should have sent you a P.M. before jumping to conclusions.
Did you notice my post about scene duration? I have a routine that works with my alarm clock app and Tasker to run through some Lifx scenes to simulate a sunrise and sunset and it would be a lot better if the transitions were less abrupt. If I could shift between scenes over 10 minutes that would be pretty sweet. Doable?
Thanks.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on August 12, 2017, 10:14:57 pm
Joe,

Would you consider modifying this to run the LIFX LAN API instead? Eliminates cloud/internet issues and should make it quicker and more reliable.

I've looked into operating the Lifx bulbs via local LAN some time ago, but determined using the lifx Rest API would be easier to implement. Plus not certain how to implement Lan portion on the vera, so would have to run a local server.

Joe

I've been working on a plugin based loosely off the work done here.  At this time it is only for UI7 and supports on/off, brightness and color via the user interface. It also periodically updates the light to reflect changes made outside Vera (on/off and brightness).

It's still early work in progress, but if folks are interested I will publish it and we can go forward based on suggestions (probably start a new thread). The vision for this plugin was from the point of view of advanced configuration (pulsing, movement etc) being set by the lifx app (this applies especially to the light strip) and the basic things controlled by vera.

-Majimus

Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on August 12, 2017, 10:20:24 pm
Awesome! I'm really excited about this! You are a hero in my eyes.  ;D
I would definitely be interested in testing the plugin and making suggestions if that would help you in any way.
THANKS!!!
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on August 12, 2017, 10:52:31 pm
You can find the code at https://github.com/majimus/majimusLifx (https://github.com/majimus/majimusLifx) , this is really beta and ONLY for UI7.

I've been using it as I develop, but at this point there is still a lot of work to be done so.

To install:

1. Upload all files to your vera (running UI7)
2. Add a new device with device type = urn:schemas-majimus-com:device:Lifx:1
3. The upnp device filename = D_MajimusLifx.xml
4. The upnp implementation filename = I_MajimusLifx.xml

You will probably need to reload the interface for the new device to appear then u click the settings section for the configuration and you add your Lifx ApiKey and the id (the format for the id is "id:xxxxxx" without the quotes) of the light in question.

The steps will need to be adjusted for each light you want to add (you can probably get away with putting "all") as the id and controlling all your lights at once.

Going forward I will move this to a parent->child setup since most people will be controlling all lights with the same token, as it is you can control lights from different accounts.

I'm happy to make changes based on feedback as time permits (but I do have a day job so you know how it goes)

-Majimus
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on August 13, 2017, 12:19:19 am
Thanks for the files and directions. I managed up until the point where I need to add the ID for the light I'm trying to control. The only way I succeed at controlling a light is by entering "group:xxxxxxxxxx" (without quotes) into the ID field, because I'm not sure where to find the ID of the individual light.

I like the idea of a parent->child setup and it makes a lot more sense to me. It would be great if there were a way to have all of the steps involved in creating each new device handled by the plugin somehow since I have 9 bulbs at present and plan on buying another 6 to 10 in the future. Not sure what to do about those that choose to use more than one token, but I'm quite certain that cases like that are fairly rare. In fact, I can't think of one reason why someone would want to generate multiple tokens to use on the same Vera.

My first request would be an additional control field for duration that allows us to enter a number in seconds for the transition duration. I believe the groundwork was already integrated in the original code posed in this thread, but I was never able to figure out how to use it.

Thanks again!
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on August 13, 2017, 12:37:49 am
Sorry about that, the automation is on the TODO list.  I kinda assumed that everyone in this thread had their id's etc.

You can go to https://api.developer.lifx.com/docs/list-lights  and in the "Try it out" section you put "all". That will give you a list of all your lights and their id's.

For the next update will automate this part of it.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on August 13, 2017, 12:45:49 am
Nice. No need to apologize! I had done that many months ago, but it's difficult to remember the all of the steps involved. Thanks.

While I'm here, I thought of another request that would be handy -- the ability to activate scenes. Using the original code, I'm able to use the syntax:
lifx_ctrl("scene_id:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "scene")
Coupled with a duration feature (if that's even possible) it would be very powerful. I have several scenes that I time to emulate a sunrise and a set for the sunset, but the changes are very abrupt and it sort of ruins the effect I'm going for. Those 2 abilities would solve that and more.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on August 13, 2017, 01:01:26 am
Nice. No need to apologize! I had done that many months ago, but it's difficult to remember the all of the steps involved. Thanks.

While I'm here, I thought of another request that would be handy -- the ability to activate scenes. Using the original code, I'm able to use the syntax:
lifx_ctrl("scene_id:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "scene")
Coupled with a duration feature (if that's even possible) it would be very powerful. I have several scenes that I time to emulate a sunrise and a set for the sunset, but the changes are very abrupt and it sort of ruins the effect I'm going for. Those 2 abilities would solve that and more.

I can think of a few elegant ways to do that but it will take time, since you appear to be familiar with and using the original script I can modify it to do what you wish to do.

I don't know if my copy is the most updated, send me a copy (remove your api key [best practices])..and I should be able to create an amended version that will add a delay to the scene (that will be much quicker, maybe even tomorrow).
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on August 13, 2017, 01:09:33 am
No rush...  I just moved so I'm still installing light fixtures, etc.
It will be some time before I install many of the most important lights because I have a lot to organize here first.

I don't have any special files here. The only update I used was the one available in the first post of the thread, so it would be simpler for you to grab it there if you don't have an up-to-date set of files.

By delay, you mean a slow transition, correct? I know that the Android app has the ability to turn on a scene over a duration when you hold down the scene and select the time-frame, so it should be possible using the API.

Thanks
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on August 13, 2017, 01:13:43 am
Yes, I'm referring to the transition delay for the lifx scene change. I thought you were using the old script, in that case I will put it on the list of things to do.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on August 13, 2017, 01:23:04 am
Yes, I am using the old script (old being the one that was current until you arrived on the scene  ;) ).
I do use the app as well though because I have yet to find a Zwave option that functions properly with the Vera that would give me the same flexibility as the app, or at least basic functionality even. I had high hopes for the Aeotec Wallmote Quad, but I don't believe Mi Casa Verde has added it to their list of devices with full functionality yet.

Anyway, I'll be following your progress as you find time to enhance your plugin. Keep up the great work and have a nice weekend!
Title: Re: Instructions and Steps to Implement LIFX API
Post by: lfairbank on September 01, 2017, 02:32:33 am
This is so awesome!!!
I have been waiting for this for ages.

HOT TIP: you can use "group_id:xxxx" "scene_id:xxxxxx" etc instead of "id:xxxxx" to control a room from one switch
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on September 03, 2017, 03:42:06 pm
This is so awesome!!!
I have been waiting for this for ages.

HOT TIP: you can use "group_id:xxxx" "scene_id:xxxxxx" etc instead of "id:xxxxx" to control a room from one switch

I know, right?  This is this best way to use these bulbs so far (without putting an open-mic, internet connected bug in your home).
I figured out the scenes thing and posted instructions back in post #52 of this thread.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on September 05, 2017, 02:33:02 am
Uploaded a new plugin that now allows you to dynamically add all your lights and scenes from a parent device.  TLDR; Add lights and Lifx Scenes to your vera with no tinkering.

https://github.com/majimus/majimusLifx (https://github.com/majimus/majimusLifx)

This is not compatible with the previous version I would recommend removing the previous devices before using this.  If you are happy with the previous code feel free to keep using it since this version is less tolerant of manual changes.

Scenes and Lights are supported but not groups (coming soon).  Also if anyone wants to donate an Icon for the parent feel free, I'm using the scene icon from vera.

if you are using groups and are having a blast manually editing the ID's you will probably be better with the previous version for now.

Contributions are welcome (even if it's the readme).  The instructions for this version would be:
-remove the old devices
-upload the files (except the Readme)
-Manually add a new device with device_type "urn:schemas-majimus-com:device:LifxParent:1" ,  device_file "D_MajimusLifx_P.xml" ,  implementation_file "I_MajimusLifx.xml" and device_file "D_MajimusLifx_P.json".

Once you have added your device, put in your api key in the settings and you can list and sync lights and scenes.

As always this is very Beta (may have errors) and work in progress , only for UI7. Unchecking an installed device (light or scene) and syncing will REMOVE the device from your vera

Feedback appreciated.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on September 05, 2017, 02:47:28 am
Nice!
I'll give this a shot tomorrow when I'm more awake and able to focus.
I'd like to contribute more, but I'm not a programmer. However, I do have plenty of experience in design and I'd be more than happy to create any icons you need. I could even build templates so that we can have indicators that reflect different bulb states if that suits you.
Let me know, and thanks for your efforts
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on September 05, 2017, 04:08:24 pm
Something simple, the letter LIFX in two rows in a square?
Title: Re: Instructions and Steps to Implement LIFX API
Post by: jmedemar on September 06, 2017, 09:38:22 am
Something simple, the letter LIFX in two rows in a square?
Found these on google for inspiration.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on September 06, 2017, 12:59:10 pm
I vote for the last one.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on September 07, 2017, 01:13:31 am
I can recreate that logo and experiment with different colors, as long as we won't be breaking any copyrights or anything. I'll have to take care of that sometime in the next three days because I have a lot lined up at the moment.
What resolution and image size must the logos be?
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on September 07, 2017, 01:44:50 am
The plugin icons are 50x50 png's.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on September 08, 2017, 11:21:50 pm
I've uploaded another update to GitHub and also attached the files.  This update adds support for groups.

Using LIFX's cloud API works well for my needs so I probably won't put too much focus on controlling the lights directly (LAN), however if someone would be willing to undertake that then I'm happy to help.

If you notice anything not working as expected do let me know.

Title: Re: Instructions and Steps to Implement LIFX API
Post by: cybrmage on September 09, 2017, 12:08:39 am
The plugin icons are 50x50 png's.

UI5 icons are 50px X 50px...

UI7 icons are 60px X 60px...


Using LIFX's cloud API works well for my needs so I probably won't put too much focus on controlling the lights directly (LAN), however if someone would be willing to undertake that then I'm happy to help.

The WiFi/UDP Sitch controller (http://forum.micasaverde.com/index.php/topic,50722.0.html (http://forum.micasaverde.com/index.php/topic,50722.0.html)) plugin already provides local control of LIFX, ECO, SengLED and TP-Link devices.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on September 09, 2017, 05:41:07 pm
The WiFi/UDP Sitch controller (http://forum.micasaverde.com/index.php/topic,50722.0.html (http://forum.micasaverde.com/index.php/topic,50722.0.html)) plugin already provides local control of LIFX, ECO, SengLED and TP-Link devices.

This is awesome, maybe we can route some commands through your plugin?
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on September 10, 2017, 01:15:58 pm
The WiFi/UDP Sitch controller (http://forum.micasaverde.com/index.php/topic,50722.0.html (http://forum.micasaverde.com/index.php/topic,50722.0.html)) plugin already provides local control of LIFX, ECO, SengLED and TP-Link devices.

This is awesome, maybe we can route some commands through your plugin?

Maybe you could ask the plugin developer if you could use some of his code and give him credit for it somewhere? It would be nice to keep plugin installations to a minimum in order to keep things clean and efficient.

Thanks for the revision! Have you had the opportunity to look at the transition change duration?

I'll have those images for you tonight by the way.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on September 10, 2017, 04:03:07 pm
The WiFi/UDP Sitch controller (http://forum.micasaverde.com/index.php/topic,50722.0.html (http://forum.micasaverde.com/index.php/topic,50722.0.html)) plugin already provides local control of LIFX, ECO, SengLED and TP-Link devices.

This is awesome, maybe we can route some commands through your plugin?

Maybe you could ask the plugin developer if you could use some of his code and give him credit for it somewhere? It would be nice to keep plugin installations to a minimum in order to keep things clean and efficient.

Thanks for the revision! Have you had the opportunity to look at the transition change duration?

I'll have those images for you tonight by the way.

While I understand the reluctance to install plugins, a modular design (Dependency) has certain benefits such as overall smaller plugins since we don't have repeated code all over the place, as well as easier maintenance of the code in the sense of issues are fixed in one place.

One way this can work is, if the LAN support plugin is installed commands can be sent locally whenever possible and if the plugin is not installed everything goes over the LIFX cloud, the plugins can also be merged...that's a possibility if the devs see fit.

I've uploaded the changes for the duration of scenes to Github, once you have added a scene go to the advanced settings and change the SceneDuration variable it's 0 by default and represents the number of seconds for the transition. Let me know if it works as expected.

Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on September 10, 2017, 04:26:30 pm
While I understand the reluctance to install plugins, a modular design (Dependency) has certain benefits such as overall smaller plugins since we don't have repeated code all over the place, as well as easier maintenance of the code in the sense of issues are fixed in one place.
...

Would it really be smaller if I were to install both plugins, even though I have zero use for any of the "Wifi UDP Switch Controller Plugin" functions aside from the LIFX feature? I don't want to be difficult or tick you off ;), but it seems that a full-fledged LIFX plugin should be able to stand on its own and handle all facets of the bulb's capabilities.

I'm not home at the moment and won't be able to test the new revision until I return in a couple of weeks, but I thank you all the same. I have something to look forward to when I get back. I'll be sure to get back to you after I test it out.
 
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on September 10, 2017, 07:06:52 pm
Here is my initial draft. I started with an identical copy of the original in vectors (so I can change the colors if need be), and moved on to include a couple of other ideas i thought may be good. If any of these are appealing but require adjustment, let me know and I can modify the chosen version to suit your tastes. I'll isolate and size the image once you've made your selection.
Maybe you can do a poll or something?
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on September 11, 2017, 02:09:11 am
Here is my initial draft. I started with an identical copy of the original in vectors (so I can change the colors if need be), and moved on to include a couple of other ideas i thought may be good. If any of these are appealing but require adjustment, let me know and I can modify the chosen version to suit your tastes. I'll isolate and size the image once you've made your selection.
Maybe you can do a poll or something?

My vote is for the top left.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on September 11, 2017, 05:44:53 pm
Plugin can now be accessed via the app store by searching for "LIFX Plugin"   :) .  If you are running the beta code, you will need to delete the plugin before installing the one from the app store.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on September 11, 2017, 09:34:09 pm
My vote is for the top left.

Boooooooooooorrriiiiiing  ;P

As you wish. Will these work?
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on September 11, 2017, 11:49:28 pm
lol @ boring, those are awesome! thanks much. Which was your preference?
Title: Re: Instructions and Steps to Implement LIFX API
Post by: lfairbank on September 12, 2017, 02:19:38 am
Plugin can now be accessed via the app store by searching for "LIFX Plugin"   :) .  If you are running the beta code, you will need to delete the plugin before installing the one from the app store.

Congrats and thanks again, you did a great job!!
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on September 12, 2017, 05:29:02 am
lol @ boring, those are awesome! thanks much. Which was your preference?

:)  Thanks! Glad to help. Let me know if you need any more graphic elements.
I was leaning towards the first icon in the second row because it mimics the android app color-picker to an extent, plus I liked the way the image reflected that it was a multicolored bulb, but I suppose the top left is better for clarity (...or at least it appears that way before rendering it at the proper size and resolution, in any case).
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on October 05, 2017, 02:39:20 pm
FYI, if you installed version 0.7 through the app store there will be errors due to file corruptions.  I've pulled the release so please "update" (downgrade) to version 0.4 by hitting the update button.

Been having major issues with the repo on mios(vera app store), this update was to bring some performance improvements to the plugin.

If you know of someone who can assist me with my problems in the app store do reach out (i am unable to commit files).

-Maj
Title: Re: Instructions and Steps to Implement LIFX API
Post by: jmedemar on October 12, 2017, 11:44:54 am
Hi Majimus, have you had any luck updating your Lifx plugin to work with local control? I'm currently using the UDP Controller app, but group control would be so much nicer. Thanks for your work on this.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on October 12, 2017, 04:04:10 pm
That has been on my todo list, however I'm having trouble just doing basic updates to the plugin via the mios app store. I will resume development once that has been resolved.

The end goal for this plugin is a hybrid setup where direct LAN messaging will be the preferred control method. As is this plugin allows you to control lights in other properties/locations from your Vera ;-).
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on October 15, 2017, 05:20:34 pm
Hey,
I've been looking forward to trying out your new revision, but I've been pretty swamped lately.
If you are waiting on Micasaverde to fix something, we could be waiting a very loooooooonnnnggggg time. I wouldn't rely on them. I've addressed several issues to them with UI7 and the Vera Plus over a year ago and they were never resolved. I ended up finding a work-around for one issue and I've all but given up on the others. We would all be better off if you found a third-party hosting solution. Github comes to mind.
I like the idea of preferring LAN communication. I've had way to many nights where I came home drunk and found that my lights were not responding because of cloud issues. I've had some serious cases of LIFX rage.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on October 16, 2017, 04:20:38 pm
If you are waiting on Micasaverde to fix something, we could be waiting a very loooooooonnnnggggg time. I wouldn't rely on them. I've addressed several issues to them with UI7 and the Vera Plus over a year ago and they were never resolved. I ended up finding a work-around for one issue and I've all but given up on the others.

This has become apparent to me.  It's a bit sad though, one of the appeals of the platform is the sheer quantity of community based plugins. You would think that they would make it as painless as possible for the folks willing to invest their time into giving something back.

I will start working soon on the hybridization of the plugin.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on October 24, 2017, 01:33:25 am
Hello All.

Had to delete and upload again the plugin to mios app store due to issues that were not being resolved.  if you are using the plugin from the app store then its necessary to remove it and install again (a bummer I know). Also updated the Github repo.

https://apps.mios.com/plugin.php?id=8986 (https://apps.mios.com/plugin.php?id=8986)

The major improvement here is that changes(ON/OFF, brightness) made to the devices externally are reflected in your Vera in a much more efficient manner.

Debug Levels and the refresh period for status updates (DELAY) can be found and edited in the advanced settings.

The coming updates will try to provide local control for non cloud features when possible.

Title: Re: Instructions and Steps to Implement LIFX API
Post by: jmedemar on November 16, 2017, 04:17:53 pm
Hello All.

Had to delete and upload again the plugin to mios app store due to issues that were not being resolved.  if you are using the plugin from the app store then its necessary to remove it and install again (a bummer I know). Also updated the Github repo.

https://apps.mios.com/plugin.php?id=8986 (https://apps.mios.com/plugin.php?id=8986)

The major improvement here is that changes(ON/OFF, brightness) made to the devices externally are reflected in your Vera in a much more efficient manner.

Debug Levels and the refresh period for status updates (DELAY) can be found and edited in the advanced settings.

The coming updates will try to provide local control for non cloud features when possible.

Hi Majimus, I've been using your plugin (v 0.2) to create my Lifx group devices in my system. I do not have any of the individual lights added to my system, only the groups. I'm not seeing the group status update at all. It just looks like the group is off all the time. All commands (dim, on, off) work from the group device though, just the correct status isn't reflected. Do you know what might be causing this?
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on November 17, 2017, 12:52:38 am
Hi Majimus, I've been using your plugin (v 0.2) to create my Lifx group devices in my system. I do not have any of the individual lights added to my system, only the groups. I'm not seeing the group status update at all. It just looks like the group is off all the time. All commands (dim, on, off) work from the group device though, just the correct status isn't reflected. Do you know what might be causing this?

Editing this message, cause now I recall why this functionality was not provided, the premise was that folks would already have the individual lights added and presenting a group as a regular light can be somewhat confusing/misleading. Different lights in a group can have different states and intensities.

How would you like a group to report the states of it's members?  On if at least one of the group members are on and the intensity being the average?

If we can agree on this then I will provide the functionality for the next update.



Title: Re: Instructions and Steps to Implement LIFX API
Post by: jmedemar on November 17, 2017, 08:19:12 am
How would you like a group to report the states of it's members?  On if at least one of the group members are on and the intensity being the average?

If we can agree on this then I will provide the functionality for the next update.

If possible, I would like to see it reflected like it's shown in the LIFX app. It shows the group being on if any of the bulbs are on. I'm not sure on the dim value though, guess I've never paid attention to the LIFX app for that. I just set it to what I want when needed. An average would be fine for me.

Also, would it be possible to implement the StepUp/StepDown Parameters for the group devices? I use Lutron Pico Remotes to operate these lights and would like to have dimming function for scenes. Thanks you!
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on November 19, 2017, 08:48:49 pm
I've uploaded the new version with group support (status updates) as we agreed to both Github and the mios app store (they took over 6 weeks to approve the last update FYI).

Also, would it be possible to implement the StepUp/StepDown Parameters for the group devices? I use Lutron Pico Remotes to operate these lights and would like to have dimming function for scenes. Thanks you!

Will try and get the Step support in next update.

Best...

Edit: Seems like it had a bug which has been fixed and uploaded.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: jmedemar on November 20, 2017, 09:59:58 am
I've uploaded the new version with group support (status updates) as we agreed to both Github and the mios app store (they took over 6 weeks to approve the last update FYI).

Thanks Majimus! I've downloaded the newest version (0.4) using the below forced update link. I'll try it out and let you know how it goes.

Code: [Select]
http://<your.vera.ip.address>:3480/data_request?id=action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=CreatePlugin&PluginNum=8986&Version=35076
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on November 22, 2017, 02:41:45 am
I've uploaded a quick bug fix  to the app store for the updater crash on loss of internet connectivity.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: jmedemar on November 22, 2017, 05:17:24 pm
I've uploaded a quick bug fix  to the app store for the updater crash on loss of internet connectivity.
Thanks for the fix, I hadn't run into any issues yet. Everything is working great, the new status updates for the groups seem fine.

Any chance of this plugin using standard device files in a future release? This way I could use the devices in remote apps like Imperihome.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on November 22, 2017, 05:59:40 pm
I've uploaded a quick bug fix  to the app store for the updater crash on loss of internet connectivity.
Thanks for the fix, I hadn't run into any issues yet. Everything is working great, the new status updates for the groups seem fine.

Any chance of this plugin using standard device files in a future release? This way I could use the devices in remote apps like Imperihome.

It only crashes if you have an internet failure. I will change the device file in the next update.

FYI, I don't use groups as part of my normal flow (don't have that many lifx bulbs) so I will remove the test group that I had (ui clutter)...this means you guys will have to let me know if anything is not working as intended (with group updates) from here on out.

Best, Majimus
Title: Re: Instructions and Steps to Implement LIFX API
Post by: iankb on November 27, 2017, 10:07:49 am
Hi,

When I add a step to a scene that sets the dimming level and colour of a Lifx bulb, it adds two steps (as seen in the Advance Editor); one to set the dimming level, and one to set the RGB colour.

The one to set the RGB colour (e.g. 255,255,255 for white) seems to reset the dimming level.

The problem is that the plug-in seems more than likely to add the colour task after the dimming task and, with a large number of steps in the Advanced Editor, and no ability to easily rearrange the steps, this means the dimming level is effectively ignored.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: iankb on November 27, 2017, 10:17:16 am
The one to set the RGB colour (e.g. 255,255,255 for white) seems to reset the dimming level.

Would a single SetColour command of RGB=127,127,127 have the same (and quicker) effect of setting both White and 50% within the plug-in ?
Title: Re: Instructions and Steps to Implement LIFX API
Post by: iankb on November 27, 2017, 10:30:34 am
Would a single SetColour command of RGB=127,127,127 have the same (and quicker) effect of setting both White and 50% within the plug-in ?

And to answer my own question ...

Yes, it not only does alter both colour and dimming level correctly, it is quicker, and avoids the current flashing as the dimming level goes up to max, and back to the correct value.

It would be nice if the plug-in UI could do this automatically, since it is lengthy to do in the Advanced Editor, and any changes would revert if the scene is subsequently altered.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on November 27, 2017, 03:28:11 pm
As you have realized, the RGB value is converted to HSBK and since it's set last it overrides the brightness that you set.

How about setting the brightness with the slider to 1% and then letting it rise to the desired brightness via RGB?

I recognize that RGB is not the ideal way to go about this.  In the move to a standard device file as mentioned above we should have HSBK via the sliders, but in the meantime the above work around should prevent the flash.

Best...
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on November 28, 2017, 08:59:45 pm
An update providing the requested StepUp/StepDown support has been uploaded to the app store.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: jmedemar on November 29, 2017, 08:47:52 am
An update providing the requested StepUp/StepDown support has been uploaded to the app store.

I've got it installed, will test and report back. Thank you.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on November 30, 2017, 02:22:58 am
Hey,
Sorry I'm really late getting back to the party!
Can you please provide me instructions on what I need to remove if I've been using the Beta so far so that I can install the latest version from the App store? (file names to delete, modifications to files)
Thanks!
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on November 30, 2017, 08:59:23 am
Welcome back,

At this point I would advise removal of all beta files (optional) and devices (required) and then installing from app store.

Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on November 30, 2017, 11:26:25 pm
Thanks. Good to be back. :)

Would you please list the Beta files so that I don't delete anything I'm not supposed to?
Can I use the Vera web-server, or do I need to go through WinSCP?
Thanks!


Edit:  Oh yeah, I have a request, too! It would be amazing to be able to use multi-zone-selectors with our LIFX Z strips as detailed here:
https://api.developer.lifx.com/docs/selectors#multi-zone-selectors
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on December 01, 2017, 12:09:32 am
Hey, just delete the devices you created and install the plugin from the app store. You will have maybe two stray files but not an issue.

The most import step is to remove the previous devices.

What would be the use case for the zone control? Trying to think of how to present it. Of course the todo list has grown so will prolly take a while to get around to it.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on December 01, 2017, 11:41:57 pm
The most import step is to remove the previous devices.

What would be the use case for the zone control? Trying to think of how to present it. Of course the todo list has grown so will prolly take a while to get around to it.

I'll try that. Thanks.
Zone control would be a very powerful feature for creating perfect scenes. I see no way to use the Lifx android app to select the color for each zone, which is a shame. One example of how the feature could be used that I can think of off the top of my head would be blending colors across a distance where you have one or more strips that run parallel to each other, like the setup I have behind my TV for back-lighting. It would also allow us to create our own effects/simple animations with scripts that use timers ...or picture a room that has framed artwork on the walls and a continuous Lifx Z strip that runs around the perimeter of the entire room on the ceiling, hidden by a molding -- every zone lit up in red, except above the frames where they are lit in white light.  I'm sure there are many other uses, but that's all I can think of for now.
Presentation-wise, I would envision the plugin determining the number of zones and presenting a bar that is sectioned, illustrating the number of zones. Clicking on a section displays a color-wheel with RGBW value fields beside it. The user would then be able to select a color from the wheel or type the desired values in directly. Of course, there would also be the corresponding Lua commands available.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on December 03, 2017, 02:11:33 pm
The most import step is to remove the previous devices.

What would be the use case for the zone control? Trying to think of how to present it. Of course the todo list has grown so will prolly take a while to get around to it.

I'll try that. Thanks.
Zone control would be a very powerful feature for creating perfect scenes. I see no way to use the Lifx android app to select the color for each zone, which is a shame. One example of how the feature could be used that I can think of off the top of my head would be blending colors across a distance where you have one or more strips that run parallel to each other, like the setup I have behind my TV for back-lighting. It would also allow us to create our own effects/simple animations with scripts that use timers ...or picture a room that has framed artwork on the walls and a continuous Lifx Z strip that runs around the perimeter of the entire room on the ceiling, hidden by a molding -- every zone lit up in red, except above the frames where they are lit in white light.  I'm sure there are many other uses, but that's all I can think of for now.
Presentation-wise, I would envision the plugin determining the number of zones and presenting a bar that is sectioned, illustrating the number of zones. Clicking on a section displays a color-wheel with RGBW value fields beside it. The user would then be able to select a color from the wheel or type the desired values in directly. Of course, there would also be the corresponding Lua commands available.

This sounds awesome and will allow for powerful scenes via the vera, it does take us away from the move from presenting as a standard device.  Do you know of any natively supported device on vera that allows for anything similar?
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on December 03, 2017, 06:06:46 pm
I use a Fibaro RGBW controller ( https://www.fibaro.com/en/products/rgbw-controller/ ), but it does not have anywhere near the level of control as the LIFX Z strips. The strips that I bought in the past to use with the device are also far inferior (my fault since I was being cheap and buying junk on ebay). Since I bought these things, I've realized that spending a few extra bucks was a very good decision. The control that your plugin would offer would make them one of the best purchases I've ever made in the way of lighting.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Amit86 on December 26, 2017, 01:48:23 am
Hi,

I need some assistance with the plug in, for some reason I dont see any settings section, do you know why?
I have my API key but dont know where to input it.

FIXED
Note to self: never forget to scroll down..
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on January 03, 2018, 02:15:17 am
Hi,

I need some assistance with the plug in, for some reason I dont see any settings section, do you know why?
I have my API key but dont know where to input it.

FIXED
Note to self: never forget to scroll down..

I tried installing this plugin on a Vera with UI5 that I gave to my brother when I "updated" to a Vera Plus. I can't find the settings anywhere. Has anyone managed to set this up successfully with the same system? I'd love to help him and his wife to enjoy the features of the LIFX I gave him for Xmas through my old Vera. I'm kind of trying to give him an intro to home automation with these devices.
Thanks.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on January 03, 2018, 09:23:11 am
Just want to say that I have no idea what UI5 looks like, all I have is a regular vera plus. If no one knows then I can try and help you, but that's the reason why it's UI7 targeted.

Did he scroll down? ... (Really should address that)
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on January 05, 2018, 06:53:38 pm
Hey,
Next time I'm there I can take a few pictures. We did indeed try to scroll down.
Hopefully someone else that still runs UI5 will chime in.
Thanks.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on January 07, 2018, 12:10:57 pm
By the way,
I was wondering how I can repopulate the list of devices after making changes to the names short of removing and reinstalling the plugin. The ones on the Vera webserver do not currently reflect the correct names of my lights.
Thanks
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on January 07, 2018, 07:16:03 pm
you should be able to edit the names from within the vera ui.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on January 07, 2018, 07:20:50 pm
Any way you can work in a "Refresh" button? I'd rather not sit here and edit 20 some-odd light names whenever I decide to modify naming conventions.  ;)
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on January 07, 2018, 11:00:02 pm
I've uploaded this and it should refresh the device names with the next plugin update (whenever the folks at vera approve it).

Edit: this will happen automatically, no refresh button.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on January 08, 2018, 03:16:10 pm
Thanks! You're awesome!

Also, happy new year!
Title: Re: Instructions and Steps to Implement LIFX API
Post by: gdme on January 10, 2018, 04:57:21 am
Hey folks,

Just installed the Lifx Plugin from the app store (v0.6) and I have few questions:

- is this the latest version?
- do I still need to follow any of the instructions from the first page on this post after installing from the app store?
- all lifx devices and groups have shown up as an "Unknown Category" device type, is this expected as I think it's breaking my attempt at configuring the lights via Vera Concierge (these devices aren't detected)
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on January 10, 2018, 09:36:46 am
No, the instructions in the first pages are for the script that inspired the creation of this plug.

The devices not showing up is a known issue that affects other plugins as well.  The fix requires some additional work in order not to break other things and I've been a bit pressed for time lately but it is something that will be addressed in the future.

EDIT: Version 0.7 with the auto label/name refresh has been pulled, a bug was detected during tests.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: gdme on January 11, 2018, 05:31:20 pm
No worries Majimus, don't mean to hassle just getting a grip of where it's at - fantastic work by the way, great plugin :-)

Thanks for all your efforts!
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on January 16, 2018, 04:28:04 pm
Version 0.7 with the auto label/name refresh is available for download  ;).

Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on January 17, 2018, 05:02:28 pm
Thanks again!
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on January 17, 2018, 07:09:26 pm
Thanks again!

This means its working satisfactorily...nice.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on January 17, 2018, 08:53:28 pm
Thanks again!

This means its working satisfactorily...nice.

I'm actually out of town again, so I haven't been able to test it yet.  :/
But I'm still grateful that you're continuing to develop the plugin, so I wanted to say thanks all the same. I'll be sure to update as soon as I get back in a couple of weeks.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on January 17, 2018, 10:09:31 pm
Thanks again!

This means its working satisfactorily...nice.

I'm actually out of town again, so I haven't been able to test it yet.  :/
But I'm still grateful that you're continuing to develop the plugin, so I wanted to say thanks all the same. I'll be sure to update as soon as I get back in a couple of weeks.

Well I use this plugin quite a lot so I will continue to put in work when I can, really want to do the hybrid thing for faster on/off but time is against me.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on April 08, 2018, 12:18:13 pm
Hi Majimus,
I've noticed something strange with the plugin and I was wondering if you may know why it's exhibiting this behavior.
I've renamed a number of lights and deleted the old devices that were created before your revision of the plugin. For some reason a few of them keep reappearing. I've deleted them a number of times and they always come back after a while.
Any ideas?  Thanks!
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on April 08, 2018, 04:33:09 pm
Hi Majimus,
I've noticed something strange with the plugin and I was wondering if you may know why it's exhibiting this behavior.
I've renamed a number of lights and deleted the old devices that were created before your revision of the plugin. For some reason a few of them keep reappearing. I've deleted them a number of times and they always come back after a while.
Any ideas?  Thanks!

Did you delete them via Vera or via the plugin? chances are if you simply delete via vera..then some time later when you have a restart of the engine, the plugin will re-add the deleted lights when it(plugin) goes through it's startup sequence.

If you have deleted them via the plugin we may have to look into it.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on April 08, 2018, 04:45:32 pm
I deleted them manually, then went into the plugin configuration, listed devices and checked off only the existing lights and hit the sync button.
I've just repeated the sequence one last time to verify that it's still re-adding those three devices and I'll report back again.

By the way, I know your time is scarce, but have you had a chance to look at that feature of selecting colors for the zones on a strip by any chance?  I was sitting in front of my 8' aquarium the other night thinking about how cool it would be if I could create mini-scenes in my tank.  ;)

Thanks
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on April 08, 2018, 05:06:57 pm
Yup. Those pesky devices keep reappearing, despite the fact that they were renamed long ago and now exist on the Vera under a different name already. :-\
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on April 08, 2018, 07:29:47 pm
Can you send me a pm with a screenshot of advanced settings page for one of the misbehaving devices.

I have not been doing much with the plugin lately so all planned updates are kind of on hold.

EDIT:  Just posting this update, after some back and forth we have determined that there was some user confusion but no bug here, best.

Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on April 12, 2018, 01:12:35 pm
Apologies for not updating the thread. The confusion stemmed from devices that were named the same as the groups that they were part of, as well as a device that I had turned off at the switch and thought that I had already renamed it.  My bad.  :-[

I've noticed that my scripts have suddenly stopped working now. Can someone else please try some out and let me know if it's just me?  Hopefully I've just overlooked something again, though I'm relatively certain there is something actually wrong here. I had these working only days ago and made no changes.

Thanks
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on April 12, 2018, 03:59:52 pm
Apologies for not updating the thread. The confusion stemmed from devices that were named the same as the groups that they were part of, as well as a device that I had turned off at the switch and thought that I had already renamed it.  My bad.  :-[

I've noticed that my scripts have suddenly stopped working now. Can someone else please try some out and let me know if it's just me?  Hopefully I've just overlooked something again, though I'm relatively certain there is something actually wrong here. I had these working only days ago and made no changes.

Thanks

No problem, when you say your scripts have stopped working? you had some custom lua/scene scripts? or the plugin is not working properly for you?
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on April 12, 2018, 09:02:21 pm
The plugin seems to work great as far as toggling lights manually but I have several scenes that I had created long ago that I trigger with Tasker on my Android phone to act as notifications. Up until recently these were working pretty much flawlessly. Now they don't do anything when the events happen and when I try to trigger them manually I see a message that says that they were executed successfully, but nothing actually occurs with the lights. The scripts are entered as a manual triggered scene, under the area titled "Also, execute the following Luup code:"
An example of that code would be:
lifx_ctrl("all", "breathe", "blue",1,5,1)
 but I've also tried specific groups with the sytax:
lifx_ctrl("group:Bedroom", "breathe", "blue",1,5,1)
and that fails to work as well. Not sure why this suddenly stopped working since I've had these running for many months.

Edit: At this point I'm wondering if if could be that some files have been somehow mysteriously corrupted on the Vera.

Thanks!
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on April 12, 2018, 09:37:54 pm
The plugin seems to work great as far as toggling lights manually but I have several scenes that I had created long ago that I trigger with Tasker on my Android phone to act as notifications. Up until recently these were working pretty much flawlessly. Now they don't do anything when the events happen and when I try to trigger them manually I see a message that says that they were executed successfully, but nothing actually occurs with the lights. The scripts are entered as a manual triggered scene, under the area titled "Also, execute the following Luup code:"
An example of that code would be:
lifx_ctrl("all", "breathe", "blue",1,5,1)
 but I've also tried specific groups with the sytax:
lifx_ctrl("group:Bedroom", "breathe", "blue",1,5,1)
and that fails to work as well. Not sure why this suddenly stopped working since I've had these running for many months.

Edit: At this point I'm wondering if if could be that some files have been somehow mysteriously corrupted on the Vera.

Thanks!

Ahh, you are referring to the original script and not the plugin.   I'm sorry,  not a user of the script.....that being said if it's a widespread problem and the OP is not around I can take a look,
Title: Re: Instructions and Steps to Implement LIFX API
Post by: lfairbank on April 12, 2018, 10:48:20 pm
The plugin seems to work great as far as toggling lights manually but I have several scenes that I had created long ago that I trigger with Tasker on my Android phone to act as notifications. Up until recently these were working pretty much flawlessly. Now they don't do anything when the events happen and when I try to trigger them manually I see a message that says that they were executed successfully, but nothing actually occurs with the lights. The scripts are entered as a manual triggered scene, under the area titled "Also, execute the following Luup code:"
An example of that code would be:
lifx_ctrl("all", "breathe", "blue",1,5,1)
 but I've also tried specific groups with the sytax:
lifx_ctrl("group:Bedroom", "breathe", "blue",1,5,1)
and that fails to work as well. Not sure why this suddenly stopped working since I've had these running for many months.

Edit: At this point I'm wondering if if could be that some files have been somehow mysteriously corrupted on the Vera.


Mine are not working either, stopped about 2 weeks ago. My guess is that the API has changed slightly. I only use this for the things the plugin cant do, ie pulse and breathe

Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on April 12, 2018, 11:05:06 pm
Ahh, you are referring to the original script and not the plugin.   I'm sorry,  not a user of the script.....that being said if it's a widespread problem and the OP is not around I can take a look,

Like Ifairbank, I use these scripts for those functions that are not available in the plugin. It would be a shame to lose these because I find it's one of the most useful features of these lights. I have different signals for everything from my doorbell being activated to receiving texts and emails, alarm system status changes and receiving phone calls (handy when I'm in the shower or listening to loud music).
Unfortunately, the OP disappeared quite some time ago.

Is there a different scripting convention for your plugin, or is it absent altogether?

Thanks, Majimus!  (and thanks Ifairbank for your feedback)
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on April 12, 2018, 11:09:46 pm
Ahh, you are referring to the original script and not the plugin.   I'm sorry,  not a user of the script.....that being said if it's a widespread problem and the OP is not around I can take a look,

Like Ifairbank, I use these scripts for those functions that are not available in the plugin. It would be a shame to lose these because I find it's one of the most useful features of these lights. I have different signals for everything from my doorbell being activated to receiving texts and emails, alarm system status changes and receiving phone calls (handy when I'm in the shower or listening to loud music).
Unfortunately, the OP disappeared quite some time ago.

Is there a different scripting convention for your plugin, or is it absent altogether?

Thanks, Majimus!  (and thanks Ifairbank for your feedback)

Over time I've made small changes here and there but I will take a look right now.

EDIT: Question....Does nothing from the script work or is it only the breathe and pulse that has stopped? I can probably whip this up right right now....
Title: Re: Instructions and Steps to Implement LIFX API
Post by: lfairbank on April 12, 2018, 11:25:35 pm
Ahh, you are referring to the original script and not the plugin.   I'm sorry,  not a user of the script.....that being said if it's a widespread problem and the OP is not around I can take a look,

Like Ifairbank, I use these scripts for those functions that are not available in the plugin. It would be a shame to lose these because I find it's one of the most useful features of these lights. I have different signals for everything from my doorbell being activated to receiving texts and emails, alarm system status changes and receiving phone calls (handy when I'm in the shower or listening to loud music).
Unfortunately, the OP disappeared quite some time ago.

Is there a different scripting convention for your plugin, or is it absent altogether?

Thanks, Majimus!  (and thanks Ifairbank for your feedback)

Over time I've made small changes here and there but I will take a look right now.

EDIT: Question....Does nothing from the script work or is it only the breathe and pulse that has stopped? I can probably whip this up right right now....

Just breathe and pulse, I am looking at the moment, only thing that stands out is that brightness isnt listed as an option in the API anymore (for breathe and pulse). On/Off/Toggle etc still work
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on April 12, 2018, 11:31:30 pm
I currently only use breathe, pulse and activate scene.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: lfairbank on April 12, 2018, 11:45:07 pm
Ahh, you are referring to the original script and not the plugin.   I'm sorry,  not a user of the script.....that being said if it's a widespread problem and the OP is not around I can take a look,

Like Ifairbank, I use these scripts for those functions that are not available in the plugin. It would be a shame to lose these because I find it's one of the most useful features of these lights. I have different signals for everything from my doorbell being activated to receiving texts and emails, alarm system status changes and receiving phone calls (handy when I'm in the shower or listening to loud music).
Unfortunately, the OP disappeared quite some time ago.

Is there a different scripting convention for your plugin, or is it absent altogether?

Thanks, Majimus!  (and thanks Ifairbank for your feedback)

Over time I've made small changes here and there but I will take a look right now.

EDIT: Question....Does nothing from the script work or is it only the breathe and pulse that has stopped? I can probably whip this up right right now....

Just noticed that on doesnt work either so it is color more than likely as this is the only required field for those functions.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on April 12, 2018, 11:47:47 pm
working on it.....
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on April 13, 2018, 12:05:20 am
Here we go, a few lil changes here and there....as before, you need to put your token in the file BEFORE uploading it to your wonderful vera.

....have a fun time!!
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on April 13, 2018, 12:07:17 am
Wow, that was fast!  You're a wizard!
Thanks for hooking us up. I'll try it now.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: lfairbank on April 13, 2018, 12:15:13 am
Here we go, a few lil changes here and there....as before, you need to put your token in the file BEFORE uploading it to your wonderful vera.

....have a fun time!!

My Man!!! works like a charm
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on April 13, 2018, 12:18:36 am
Good times gentlemen......good times
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on April 13, 2018, 12:21:43 am
Excellent. My notifications are back up and running and scripted color changes work perfectly. I can't find which scenes have scripted scene changes because I have too many to go through, but I'm confident that it's going to work without a hitch.

Thanks again --  we owe you!!

Edit:
Scene activation functionality verified. Just to reiterate for those that don't want to read 10 pages of posts, the syntax is:
lifx_ctrl("scene_id:XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", "scene")
You can find your list of scenes here after pasting your API key in at the bottom, under "try it out":
https://api.developer.lifx.com/docs/list-scenes
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on April 13, 2018, 01:05:26 am
May have found an error.
When using "Pulse", the scripts don't seem to be able to flash the lights quickly (ie.- 0.1), whereas when I try it on the LIFX developer site I can have them basically strobe.
Is this an accidental limitation?
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on April 13, 2018, 01:12:29 am
there is no modification of your values, what happens when you put 0.1?
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on April 13, 2018, 01:13:49 am
It just pulses at around once per second.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on April 13, 2018, 01:14:53 am
does it pulse slower than 1 second i.e 2 seconds? already deleted the script from my vera.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on April 13, 2018, 01:18:17 am
No. It seems that regardless of the first parameter it will pulse at approximately once per second.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on April 13, 2018, 01:19:27 am
can you paste the the call to the script? The last parameter defines your period....

Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on April 13, 2018, 01:22:31 am
Certainly.  Originally the code was:

lifx_ctrl("group:Bedroom", "pulse", "green",0.2,5,1)

but this doesn't work with a longer pulse cycle either:

lifx_ctrl("group:Bedroom", "pulse", "green",3,5,1)

Both are identical in their performance.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on April 13, 2018, 01:25:57 am
Certainly.  Originally the code was:

lifx_ctrl("group:Bedroom", "pulse", "green",0.2,5,1)

but this doesn't work with a longer pulse cycle either:

lifx_ctrl("group:Bedroom", "pulse", "green",3,5,1)

Both are identical in their performance.

 Usage is as follows lifx_ctrl(selector, mode, color, bright, cycles, period)  FYI bright is not a parameter of the pulse and breathe (AFAIK) so this value will be ignored for those features, but you MUST put something there.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on April 13, 2018, 01:27:31 am
AAArrrgh!
Thanks for clearing that up.   :-[
What about persistence?
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on April 13, 2018, 01:29:41 am
"persist:
booleanfalse

If false set the light back to its previous value when effect ends, if true leave the last effect color.
"
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on April 13, 2018, 01:30:33 am
AAArrrgh!
Thanks for clearing that up.   :-[
What about persistence?

Persistence is hard-coded in the script...
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on April 13, 2018, 01:31:52 am
Okay,  cool.  Works for me.
 Thanks!
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on April 13, 2018, 01:34:22 am
Okay,  cool.  Works for me.
 Thanks!

Alrighty, this has used up all my "vera time"  for about a good month  ;D .....have fun.....go easy with the strobes...Later.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on April 21, 2018, 04:05:43 pm
Alrighty, this has used up all my "vera time"  for about a good month  ;D .....have fun.....go easy with the strobes...Later.

Hey Majimus,
I know you explicitly stated that you've expended more than your share of time on this for a good while (agreed), but I've been investing a lot of time myself recently (albeit not charitably) on setting up a number of elements that are dependent on this plugin and I just wanted to come beg for another feature. It shouldn't be too complicated for someone of your coding caliber (ok, that was admittedly ass-kissing). If you're ever in Montreal, Qc I'll buy you a beer or two.  ;)
I've noticed in the past that there is a variable hidden in the script that dictates the time period over which a scene takes effect, but I have no idea how to use it. I've been hoping to set up my sunrise emulator to make use of this feature that's present in the API but so far I'm at a loss.
What are the chances that you could take a few minutes to look at this and see if it's feasible?
Thanks in advance!

-D
Title: Re: Instructions and Steps to Implement LIFX API
Post by: mhickey on April 22, 2018, 02:15:46 am
I have been using the lifx_ctrl plugin for some time. Mine stopped working a few weeks ago for no apparent reason. Specifically just turning lights on. Turing off and toggle seems fine. I suspect a change in API. Sounds like I am not alone reading Ifairbank and Quixote posts.

I was pleased to see the development work from Majimus (thank you for your efforts!) and installed the V0.7 plugin. Happy with the result, just not sure how to configure the colours/whites to be specific? ie. With the lifx_ctrl I could specify 2750K white colour temperature. Is there a way I can get this type of control in my scenes?

Thanks,
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on April 22, 2018, 02:16:13 pm
Alrighty, this has used up all my "vera time"  for about a good month  ;D .....have fun.....go easy with the strobes...Later.

Hey Majimus,
I know you explicitly stated that you've expended more than your share of time on this for a good while (agreed), but I've been investing a lot of time myself recently (albeit not charitably) on setting up a number of elements that are dependent on this plugin and I just wanted to come beg for another feature. It shouldn't be too complicated for someone of your coding caliber (ok, that was admittedly ass-kissing). If you're ever in Montreal, Qc I'll buy you a beer or two.  ;)
I've noticed in the past that there is a variable hidden in the script that dictates the time period over which a scene takes effect, but I have no idea how to use it. I've been hoping to set up my sunrise emulator to make use of this feature that's present in the API but so far I'm at a loss.
What are the chances that you could take a few minutes to look at this and see if it's feasible?
Thanks in advance!

-D

Scene devices (should) have a parameter called "SceneDelay" changing this (advanced settings) should get you sorted....sadly I don't envision myself in Montreal anytime soon.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on April 22, 2018, 02:18:58 pm
Shame. Well, there's no expiry date on that offer.
Thanks for the pointer. Is that "scriptable"? If so, what would be the syntax?
Thanks!
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on April 22, 2018, 03:03:11 pm
Shame. Well, there's no expiry date on that offer.

I accept gifts... 8)

Now for the business at hand....you should be able to do something like:

Code: [Select]
luup.variable_set("urn:majimus-com:serviceId:Lifx", "SceneDelay", DEVICEID_FROM_VERA, DELAY)
Check in the advanced settings to verify that the value was changed, I have no scenes to test and I'm working on another spare time project atm.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on April 22, 2018, 03:08:39 pm
I'll check it out this evening and post back with my findings. Thanks again and good luck with your project.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on April 22, 2018, 10:17:35 pm
No luck. The scene delay setting remains at 0.  :(
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on April 23, 2018, 03:35:10 am
No luck. The scene delay setting remains at 0.  :(

I can confirm that it does not work....the ecosystem is fairly esoteric, the following will work AFTER the next upgrade will leave it here anyways

Code: [Select]
luup.call_action("urn:majimus-com:serviceId:Lifx", "SetSceneDelay", {["newSceneDelayValue"] = "Delay"}, DEVICEID_FROM_VERA)
Will try and upload the new code during the upcoming week (will test for a few days just in case).
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on April 23, 2018, 08:18:27 am
I can confirm that it does not work....the ecosystem is fairly esoteric, the following will work AFTER the next upgrade will leave it here anyways

Code: [Select]
luup.call_action("urn:majimus-com:serviceId:Lifx", "SetSceneDelay", {["newSceneDelayValue"] = "Delay"}, DEVICEID_FROM_VERA)

Very cool, but does this mean that we'll need to have the same setting for every scene? That could be less than ideal for certain situations, for example a scripts that emulate the sunrise by phasing through a few scenes over an hour vs. activating a scene that comes on when "movie mode" is set. It would be strange to wait 20 minutes for the lights to change while the movie plays. I guess I'm just being picky and we could change the setting before activating each scene, but that seems a little rough around the edges.

In any case, I'm very happy for anything you can offer in the way of a solution when time permits! Thanks
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on April 23, 2018, 12:48:22 pm
Very cool, but does this mean that we'll need to have the same setting for every scene? That could be less than ideal for certain situations, for example a scripts that emulate the sunrise by phasing through a few scenes over an hour vs. activating a scene that comes on when "movie mode" is set. It would be strange to wait 20 minutes for the lights to change while the movie plays. I guess I'm just being picky and we could change the setting before activating each scene, but that seems a little rough around the edges.

This setting is per scene (already is this way in current version) and not global for all scenes in fact this has no meaning in the context of the controller (Lifx plugin), the idea here is that the user added the scenes as devices, and as such will make this change to the devices that corresponds to the scene.

If the transition delay for each scene is fixed you can simply go to each scene's advanced settings and make the change. 

If you are running the same lifx scenes with different transition periods within vera scenes what do you suggest would be a more refined approach to doing this? I'm trying to understand the alternative to setting new delay for a lifx scene run.

Will need to open a new thread for this plugin soon so that I put a readme etc etc....it is beyond time for that.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on April 23, 2018, 01:11:20 pm
If you are running the same lifx scenes with different transition periods within vera scenes what do you suggest would be a more refined approach to doing this? I'm trying to understand the alternative to setting new delay for a lifx scene run.

Ah yes, of course. I failed to notice the "DEVICEID_FROM_VERA" tacked onto the end of that line somehow. Never try to do anything that requires any amount of concentration on 5 hours of sleep.  :o

I think it would be nice if any line of script includes a duration variable that will override the advanced settings of the device (temporarily). So maybe something like:
Code: [Select]
lifx_ctrl("scene_id:XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", "scene", 360)where the 360 at the end indicates the number of seconds over which the transition is performed (with the same option for turning lights on or off, not just scene transitions).

What do you think? Do-able?
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on April 29, 2018, 03:02:55 pm
If you are running the same lifx scenes with different transition periods within vera scenes what do you suggest would be a more refined approach to doing this? I'm trying to understand the alternative to setting new delay for a lifx scene run.

Ah yes, of course. I failed to notice the "DEVICEID_FROM_VERA" tacked onto the end of that line somehow. Never try to do anything that requires any amount of concentration on 5 hours of sleep.  :o

I think it would be nice if any line of script includes a duration variable that will override the advanced settings of the device (temporarily). So maybe something like:
Code: [Select]
lifx_ctrl("scene_id:XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", "scene", 360)where the 360 at the end indicates the number of seconds over which the transition is performed (with the same option for turning lights on or off, not just scene transitions).

What do you think? Do-able?

Yes, you will need to amend your script and add the duration parameter in the payload section for the scene change.  My recommendation would be to keep the interface standard (use one of the existing params for the duration) and just put placeholder values for parameters that will be ignored when you make the function call.

The plugin update that would allow you to do what I mentioned previously is still under review.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on April 29, 2018, 03:11:43 pm
Ok, well I'm confident that whatever you think is best will work out better since you have a much deeper understanding of how this works, obviously.
So if we are running the same lifx scenes with different transition periods within Vera scenes, we would just include a line to change the variable that dictates the scene change duration before the command to execute the LIFX scene (or as I understand now, "device") and then include a line at the end to return the variable to its previous value before the script ends?
Thanks
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on April 29, 2018, 03:37:06 pm
Ok, well I'm confident that whatever you think is best will work out better since you have a much deeper understanding of how this works, obviously.
So if we are running the same lifx scenes with different transition periods within Vera scenes, we would just include a line to change the variable that dictates the scene change duration before the command to execute the LIFX scene (or as I understand now, "device") and then include a line at the end to return the variable to its previous value before the script ends?
Thanks

Alright, that sounds a little convoluted.

I will modify the script, won't test it though (fairly harmless change) so someone will have to take the plunge (harmless is in the eyes of the beholder). 

Best........
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on April 29, 2018, 03:49:16 pm
This will work in the following way:

Code: [Select]
lifx_ctrl("scene_id:XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", "scene", nil, nil, nil, DURATION)
the last parameter will control the duration....very much aware of the dire need for a new thread with updated instructions and usage guidelines etc etc.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on April 29, 2018, 04:58:36 pm
Excellent!  Thanks for taking care of that so quickly. Just in the middle of installing a bunch of recessed lights at the moment (to take advantage of my new LIFX abilities  ;)), but I'll try that file out tonight for sure!
Maybe I'll set up a bunch of scripts for my wake up routine tomorrow morning and put it through the gauntlet. I'll let you know how it goes.

One of these days soon I'll go through the 13 pages of this thread and collect all of the important stuff, then I'll see if there is anything I can add to that, send it to you for your review and you can post it in a new thread. Maybe we can request that the post is "stickied" while we're at it.

Take care!
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Quixote on April 29, 2018, 08:03:31 pm
Unfortunately, it's not working for me.
I've uploaded the new file, changed the syntax of my script and rebooted the Vera. The scene says that it's been executed successfully, but I see no results.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on April 29, 2018, 08:09:07 pm
I will check later....so I've tested the code and it works, what did you do?


example usage is:

lifx_ctrl("scene_id:xxxxx-xxx-xxxx-xxxx", "scene", nil, nil, nil, 3)
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on April 29, 2018, 10:29:40 pm
I've created a new topic for the plugin

http://forum.micasaverde.com/index.php/topic,80853.0.html (http://forum.micasaverde.com/index.php/topic,80853.0.html)

We can take up further discussion over there, not having access to the first post makes it hard to consolidate information.

maj..
Title: Re: Instructions and Steps to Implement LIFX API
Post by: jjwalker on November 10, 2018, 11:17:30 pm
I have been using the lifx_ctrl plugin for some time. Mine stopped working a few weeks ago for no apparent reason. Specifically just turning lights on. Turing off and toggle seems fine. I suspect a change in API. Sounds like I am not alone reading Ifairbank and Quixote posts.

I was pleased to see the development work from Majimus (thank you for your efforts!) and installed the V0.7 plugin. Happy with the result, just not sure how to configure the colours/whites to be specific? ie. With the lifx_ctrl I could specify 2750K white colour temperature. Is there a way I can get this type of control in my scenes?

Thanks,

Did you ever figure out the "turning on" problem?  I just installed the script... a bit confused about the actual plugin though.  Like you, I'm able to luup code turning off a light.  Can't get it to turn on though.

Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on November 11, 2018, 01:42:33 am
Did you ever figure out the "turning on" problem?  I just installed the script... a bit confused about the actual plugin though.  Like you, I'm able to luup code turning off a light.  Can't get it to turn on though.

What about the plugin confuses you?
Title: Re: Instructions and Steps to Implement LIFX API
Post by: jjwalker on November 11, 2018, 08:12:36 am
It doesn't show up in the devices list.  The older plugin says "Lifx starting.." or something like that.  No devices show up after installing either plugin.  I got the lifx_ctrl script to work... but only to turn off a light. Can't seem to turn it on.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: jjwalker on November 11, 2018, 08:30:57 am
Oh wait! I'm reading the new thread and didnt see the 3 updated files.  I'll try that!
Title: Re: Instructions and Steps to Implement LIFX API
Post by: jjwalker on November 11, 2018, 08:42:12 am
ok nevermind.  Luup code to turn on light still doesnt work.  plugin is not showing up.  Yeah Im a bit confused.  Is the plugin only for UI7?

EDIT
Ok I see Lifx Plugin shows up in advance scene editor (after reading some more, my fault).  But there are really no options for actual control of the lights.  Im rebooting the vera right now.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: Majimus on November 11, 2018, 02:27:28 pm
The plugin is only for UI7, that is all I have to test.  I don't know if/how it will work for you.

The plugin is a totally separate entity from the scripts that I tried to update and keep going for the other folks...they have nothing to do one with the other. I assume that the scripts are working fine, else someone would have complained already.
Title: Re: Instructions and Steps to Implement LIFX API
Post by: jjwalker on November 11, 2018, 04:15:10 pm
Ahh I see.  The script works.  I just can't get the "on" function to work.  Somebody else had the same issue on this thread.  He mentioned Lifx might have changed somethings in the API.  I tried different strings in their API and still can't get "on" to work.  "off" works though.  Thanks, I'll try the plugin in a UI7 box.