Author Topic: Instructions and Steps to Implement LIFX API  (Read 10384 times)

Offline stibbzy

  • Sr. Newbie
  • *
  • Posts: 29
  • Karma: +1/-0
Re: Instructions and Steps to Implement LIFX API
« Reply #15 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?

Offline joek

  • Sr. Newbie
  • *
  • Posts: 48
  • Karma: +7/-0
Re: Instructions and Steps to Implement LIFX API
« Reply #16 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

Offline stibbzy

  • Sr. Newbie
  • *
  • Posts: 29
  • Karma: +1/-0
Re: Instructions and Steps to Implement LIFX API
« Reply #17 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!

Offline Quixote

  • Full Member
  • ***
  • Posts: 245
  • Karma: +9/-32
Re: Instructions and Steps to Implement LIFX API
« Reply #18 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.
My "Karma" has been modified by 2 or 3 douchebags that didn't like that I criticized the plugin that they worship. I'm not actually a bad person.

Offline joek

  • Sr. Newbie
  • *
  • Posts: 48
  • Karma: +7/-0
Re: Instructions and Steps to Implement LIFX API
« Reply #19 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
« Last Edit: July 23, 2016, 12:16:02 pm by joek »

Offline Quixote

  • Full Member
  • ***
  • Posts: 245
  • Karma: +9/-32
Re: Instructions and Steps to Implement LIFX API
« Reply #20 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
My "Karma" has been modified by 2 or 3 douchebags that didn't like that I criticized the plugin that they worship. I'm not actually a bad person.

Offline stibbzy

  • Sr. Newbie
  • *
  • Posts: 29
  • Karma: +1/-0
Re: Instructions and Steps to Implement LIFX API
« Reply #21 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.

Offline Quixote

  • Full Member
  • ***
  • Posts: 245
  • Karma: +9/-32
Re: Instructions and Steps to Implement LIFX API
« Reply #22 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
My "Karma" has been modified by 2 or 3 douchebags that didn't like that I criticized the plugin that they worship. I'm not actually a bad person.

Offline Quixote

  • Full Member
  • ***
  • Posts: 245
  • Karma: +9/-32
Re: Instructions and Steps to Implement LIFX API
« Reply #23 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
« Last Edit: September 05, 2016, 01:31:50 am by Quixote »
My "Karma" has been modified by 2 or 3 douchebags that didn't like that I criticized the plugin that they worship. I'm not actually a bad person.

Offline joek

  • Sr. Newbie
  • *
  • Posts: 48
  • Karma: +7/-0
Re: Instructions and Steps to Implement LIFX API
« Reply #24 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

Offline Quixote

  • Full Member
  • ***
  • Posts: 245
  • Karma: +9/-32
Re: Instructions and Steps to Implement LIFX API
« Reply #25 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
My "Karma" has been modified by 2 or 3 douchebags that didn't like that I criticized the plugin that they worship. I'm not actually a bad person.

Offline joek

  • Sr. Newbie
  • *
  • Posts: 48
  • Karma: +7/-0
Re: Instructions and Steps to Implement LIFX API
« Reply #26 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.
« Last Edit: October 01, 2016, 01:14:57 pm by joek »

Offline joek

  • Sr. Newbie
  • *
  • Posts: 48
  • Karma: +7/-0
Re: Instructions and Steps to Implement LIFX API
« Reply #27 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!

Offline Quixote

  • Full Member
  • ***
  • Posts: 245
  • Karma: +9/-32
Re: Instructions and Steps to Implement LIFX API
« Reply #28 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.
My "Karma" has been modified by 2 or 3 douchebags that didn't like that I criticized the plugin that they worship. I'm not actually a bad person.

Offline Hippogriff

  • Jr. Member
  • **
  • Posts: 79
  • Karma: +2/-2
Re: Instructions and Steps to Implement LIFX API
« Reply #29 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.
Cheers, Hippo