delfick / photons

Python3.6+ asyncio framework for interacting with LIFX devices
https://photons.delfick.com
MIT License
71 stars 6 forks source link

Photons for Home Assistant #61

Closed Kackerlacka closed 2 years ago

Kackerlacka commented 3 years ago

Is there any thought for a Photons Integration in Home Assistant as an addon or HACS integration? I would love a simple, intuitive way to control the individual zones in my Tiles and Candle Color through Home Assistant, but I'm really struggling to find any possible way to do so without actually creating an integration for it (which with my little Python knowledge seems out of the realm of possibility for me).

Home Assistant currently has very poor support for LIFX Tiles and Candle Color (it has zero ability to control individual zones), so there's very little room for customization outside of single, static colors and the morph and flame effects (currently only achievable by using REST commands and the LIFX HTTP API). Photons obviously has fantastic support for the Tiles - and presumably Candle Color - but with very little Python knowledge I have no way to connect Photons to Home Assistant.

delfick commented 3 years ago

Hi

I also think photons would be a good companion to Home Assistant. I think the easiest way to do that would be to make a plugin to home assistant that talks http/websockets to photons interactor. That does mean the user would have to make interactor work, but I think that shouldn't be too much of a problem given they have to do that for Home Assistant anyway.

The problem becomes is that I do not have the time. My mental health took a dramatic nosedive last year and I'm still recovering. That recovery includes being a bit more deliberate with how I manage my time and workload and the side projects just don't have priority; and Home Assistant integration isn't something I need for the private copy of Photons.

Also, I've never used Home Assistant myself and so there's an extra learning cost for something I don't use.

I'm sure there will be a point in the (far) future where I find the time for doing this, but until then it'd have to be done by someone else.

Kackerlacka commented 3 years ago

Very understandable. Hopefully someone else with more python knowledge than me can figure out a way to get Photons (or at least some method of controlling Tiles/Candle Color zones...) in Home Assistant someday.

delfick commented 3 years ago

yeah, for sure.

Final-Hawk commented 3 years ago

I like to run photons interactor in docker, then just send commands via the rest integration. Here is an example of one of sending the morph effect to my tiles though photons

rest_command:
 morph:
    url: 'http://192.168.1.84:6100/v1/lifx/command'
    method: "put"
    payload: '{"command":"effects/run", "args":{"matcher":{"label":"Tiles"},"matrix_animation": "MORPH","transform": {"power": "on"}}}'
    verify_ssl: false 

I have lots of similar commands that i just trigger though automatons or button cards. Takes some effort to get setup, but in the end it works well.

With the candle, you could try having a look at creating scenes in photons then just calling them by a http request again. I haven't tried this though.

Here are some screenshots of the scene_capture and the scene_apply commands that should help craft a scene to call. image

image

https://photons.delfick.com/apps/interactor/index.html

Final-Hawk commented 3 years ago

To add to my comment, i have just tried scenes in photons and wow they work well. Great job delfick

Here is a curl command i sent when all my lights were in the state i wanted. (You will probably want to add matcher so its just the candle)

curl -XPUT http://192.168.1.84:6100/v1/lifx/command \
  -HContent-Type:application/json \
  -d '{"command":"scene_capture", "args":{"uuid": "myuuid", "label": "myscene"}}'

then to apply it

curl -XPUT http://192.168.1.84:6100/v1/lifx/command \
  -HContent-Type:application/json \
  -d '{"command":"scene_apply", "args":{"uuid": "myuuid"}}'

So i could remember the uuid, i just used the uuid from the scene in the lifx app, gotten from here

delfick commented 3 years ago

Scene capture will create a uuid for you if you don't specify it (specifying one is how you update an existing scene) and then scene_info can be used to find uuids for the labels you've given your scenes. Probably best to try and not get confused between scenes in interactor and scenes in the LIFX Cloud

Kackerlacka commented 3 years ago

I like to run photons interactor in docker, then just send commands via the rest integration. Here is an example of one of sending the morph effect to my tiles though photons

rest_command:
 morph:
    url: 'http://192.168.1.84:6100/v1/lifx/command'
    method: "put"
    payload: '{"command":"effects/run", "args":{"matcher":{"label":"Tiles"},"matrix_animation": "MORPH","transform": {"power": "on"}}}'
    verify_ssl: false 

I have lots of similar commands that i just trigger though automatons or button cards. Takes some effort to get setup, but in the end it works well.

With the candle, you could try having a look at creating scenes in photons then just calling them by a http request again. I haven't tried this though.

Here are some screenshots of the scene_capture and the scene_apply commands that should help craft a scene to call. image

image

https://photons.delfick.com/apps/interactor/index.html

I'm running Home Assistant (HassOS) off a RPi4, so I don't think - and I may be wrong here - that I have the ability to run the interactor in docker, as I don't have access to a command line. Sending REST commands seems easy enough aside from that though...that's what I currently use (the LIFX HTTP API) to send flame/morph effect commands to Tiles/Candle.

Final-Hawk commented 3 years ago

Just tested it on hassos, as i don't use hassos personally. You seem to be able to download and access the things you need by installing the portainer addon through supervisor. This can be used to run photons. After installing it and opening the web ui, click on the "containers" tab on the side and click on 'add container'. Enter the config you see in this screenshot. image

Click on deploy and wait. When it is finished it should say starting. image

Exit out of that and download the ssh addon, if you cannot see it, enable advanced mode from your profile (bottom left). After starting that you can click on the open web ui. From there you should be able to run the commands i showed above for creating and testing the scenes. Heres an example of the help command. image

Also, i forgot to post my home assistant config for the scenes, here it is.

rest_command:
  my_scene:
    url: 'http://192.168.1.84:6100/v1/lifx/command'
    method: "put"
    payload: '{"command":"scene_apply", "args":{"uuid": "put the uuid of the created scene here"}}'
    verify_ssl: false

Hope this helps!

Kackerlacka commented 3 years ago

Thanks for the writeup, but I am a noob so I have questions... Why is your port in your URL 6100? Do I need to use that, and if so, is there anything else I need to do to use it? Also, as you've said, you use rest commands to send animations/scenes to your Tiles... I am wondering if it's possible to send rest commands for custom animations like the Pac Man animation. I'm not 100% sure if the Pac Man animation was part of Photons or another library I'm thinking of, but I would like to send a rest command to my tiles to put that animation (or other cool custom animations onto my Tiles, but I've got very little experience doing this stuff.

Final-Hawk commented 3 years ago

All good! Happy to help. The port is just the port used by photons interactor, no need to change that. The only thing in the url you need to change is the IP address. This should be the IP of the machine your home assistant is running on.

With the animations, yes pacman is apart of photons. Heres an example of the config for that

rest_command:
  pacman:
    url: 'http://put.ip.here:6100/v1/lifx/command'
    method: "put"
    payload: '{"command":"animation/start", "args":{"matcher":{"label":"name of your tiles"},"animations": "pacman","transform": {"power": "on"}}'
    verify_ssl: false

Just remember to change {"label":"name of your tiles"}, you only need to change the "name of your tiles" part in there and the IP in the URL.

Kackerlacka commented 3 years ago

So the way I understand it, the only reason this rest command works is because we installed Photons through Portainer, right? So the SSH commands are really just for testing, I don't need it for anything concrete in terms of automations, scripts, etc?

Final-Hawk commented 3 years ago

That's correct, the ssh addon was simply for testing. Its was just a simple way of sending the web requests. Once the rest commands are set up, the only thing you need to run is Photons. All Portainer did was install photons for us, so it shouldn't need to run after the install. Portainer after the install would only really be good to see the status of the photons service if something stops working ( if has crashed etc.)

Kackerlacka commented 3 years ago

Makes sense. So I'm trying to incorporate that Pac Man Rest Command into Home Assistant using my own URL, but I'm getting an "Error URL status code 400" when I call this rest command:

# LIFX PacMan Effect pacman: url: 'http://192.168.1.205:6100/v1/lifx/command' method: "put" payload: '{"command": "animation/start", "args":{"label":"Tiles"}, "animations": "pacman", "transform": {"power: "on"}}'

Hopefully if I can get this Pac Man animation working then I can tinker with the rest of the animations and all will be good. But I'm not sure what I'm doing wrong...

delfick commented 3 years ago

@Kackerlacka you've copied in the payload wrong.

Also, @Final-Hawk, transform isn't an option to animation/start :)

delfick commented 3 years ago

So what you want is

{"command": "animation/start", "args": {"animations": "pacman"}}

And by not specifying a matcher, it'll run it on all the tiles it can find.

Final-Hawk commented 3 years ago

Also, @Final-Hawk, transform isn't an option to animation/start :)

Oops Thanks for catching that

Kackerlacka commented 3 years ago

Thank you!! It works! Sort of...calling the Pac Man rest command just randomly flashes all my tiles at 100% brightness with no sign of pac man, but the fact that I've gotten Photons in HA to work with my Tiles at all speaks volumes for me! Is there a list of animations I can replace {"animations": pacman} with?

And this may be a huge longshot, but is there an easy way to control the Tile/Candle zones using a rest command? Again I apologize, I am NOT even close to being a programmer, but I would love to be able to set specific Tile zones to colors so I can make custom scenes/animations.

Thanks, guys for your help - I really appreciate you being understanding of my incredible lack of knowledge with everything lol.

delfick commented 3 years ago

what happens if you just do {"command": "animation/start"} ?

Final-Hawk commented 3 years ago

Awesome! The flashing happens when the tiles are on one of the built in firmware effect, so just change back to plain colour mode and it should work. You will also need to create a animation stop command so it will stop sending the data.

As with the zones on the candle and tiles, I'm not sure about an exact command to send the zone data to them but as I was showing before the simplest way (I think) to do that would be though scenes

delfick commented 3 years ago

For controlling candle/tile with a command, it seems @Final-Hawk is right the only way currently is via a scene. I'd have to add a command that lets you set candle/tile zones directly.

Kackerlacka commented 3 years ago

So in terms of scenes with Photons, is there really any difference between creating a special scene in the app and importing that into home assistant vs. using Photons?

Honestly I really just want to be able to re-create the "Animate" effect that's available in the app, using Photons. That and changing the color of the "flame" effect from red to blue/green!

Final-Hawk commented 3 years ago

So in terms of scenes with Photons, is there really any difference between creating a special scene in the app and importing that into home assistant vs. using Photons?

Speed and internet. Photons doesn't require internet and is a lot faster then using the cloud. That does it for me.

delfick commented 3 years ago

Though, you could use the Set64 message directly I suppose (note also that width is different on a candle):

With the set command

{
  "command": "set",
  "args": {
    "matcher": {
      "cap": "matrix"
    },
    "pkt_type": "Set64",
    "pkt_args": {
      "length": 1,
      "tile_index": 0,
      "width": 8,
      "colors_count": 2,
      "x": 0,
      "y": 0,
      "colors": [
        {
          "hue": 20,
          "brightness": 1,
          "saturation": 1,
          "kelvin": 3500
        },
        {
          "hue": 200,
          "brightness": 1,
          "saturation": 1,
          "kelvin": 9000
        }
      ]
    }
  }
}

Scenes in photons interactor is essentially the same thing as in the LIFX ecosystem but stored in a completely different place and specified in a completely different way :) A scene is a snapshot of your devices at some point.

For MORPH with blue/green you'd want

{"command": "effects/run", "args": {"matcher": {"cap": "matrix"}, "matrix_animation": "MORPH", "matrix_options": {"palette": ["blue", "green"]}}}

But the firmware on the candle and tiles doesn't look at palette for the FLAME effect and you can't change the colours for that one.

delfick commented 3 years ago

it should be easy to add a command specifically for setting zones on a tile/candle. I'll see when I can find time to do that.

delfick commented 3 years ago

Photons doesn't implement most of the effects in the app. When I rewrote the tile animation code last year I made it possible to add the ability to send commands to devices that aren't tiles but have never found the time to do that. Once that happens then it's a bit more possible to add most of the effects in the app.

Also, with your tiles, I recommend following this https://photons.delfick.com/apps/arranger/index.html (though, if you only have one tile set, arranging in the app should be good enough)

Kackerlacka commented 3 years ago

So in terms of scenes with Photons, is there really any difference between creating a special scene in the app and importing that into home assistant vs. using Photons?

Speed and internet. Photons doesn't require internet and is a lot faster then using the cloud. That does it for me.

Agreed with the speed aspect. But from my undertanding sending a REST command to Photons would have just as much latency as sending a REST command using the normal LIFX HTTP API right? Or am I wrong there? Does sending a REST command to Photons enact some LAN-only stuff that executes super quickly compared to HTTP? I was under the impression that the REST API in general is an HTTP-based thing...but what do I know.

And delfick, to answer your question, just running {"command": "animation/start"} does the same thing as running the pacman animation - my Tiles flash random 100% brightness colors like green and blue. Could be that I have to change it to a palette color instead of a separate animation like Final-Hawk said, but I actually can no longer set my Tiles to a single color after running that command, it just keeps flashing regardless of my attempts to set it's color to white. I'll look into it more tomorrow, it's probably something super obvious I'm messing up.

Lastly, is there a reason the color of the flame effect can't be changed? It seems to me like it'd be a very simple change honestly, and it'd be super cool to have blue flames. Likewise, having morph and flame on the LIFX Beam would be super cool too, but for some reason that seems impossible even with Photons.

I'll definitely look into that set command for setting the zones for my candles and tiles.

Final-Hawk commented 3 years ago

With the flashing, stop all animations running by sending the {"command": "animation/stop"} payload and {"command": "effects/stop"} payload. I have this issue when I don't do this, my effect buttons I made in HA actually run this then the effect command to prevent this

Final-Hawk commented 3 years ago

Agreed with the speed aspect. But from my undertanding sending a REST command to Photons would have just as much latency as sending a REST command using the normal LIFX HTTP API right? Or am I wrong there? Does sending a REST command to Photons enact some LAN-only stuff that executes super quickly compared to HTTP? I was under the impression that the REST API in general is an HTTP-based thing...but what do I know.

The difference is your sending a command to the machine photons is running on compared to sending it to Lifx's cloud. Photons stays inside your network and is not bottlenecked by how fast your internet or Lifx's server speed is.

delfick commented 3 years ago

The difference is your sending a command to the machine photons is running on compared to sending it to Lifx's cloud. Photons stays inside your network and is not bottlenecked by how fast your internet or Lifx's server speed is.

Exactly.

Let's say you're in Australia and you send a HTTP command to the HTTP API. Then you have a command travelling 15,000km to LIFX servers in the USA and back rather than all within the confines of your own home :)

my Tiles flash random 100% brightness colors like green and blue

That's super weird. I don't have my tiles setup atm but I don't think I've broken animations. I'm not sure what's happening there.

Can you use the LIFX app to change it to particular colours and paint on them?

Lastly, is there a reason the color of the flame effect can't be changed?

Firmware engineers didn't implement that. The tiles are now discontinued. LIFX's support for the tiles is that they will always work in the app and cloud, but there won't be new features added moving forward

Likewise, having morph and flame on the LIFX Beam would be super cool too, but for some reason that seems impossible even with Photons.

Yeap, that's a firmware effect and difficult (impossible I think) to replicate with messages and it's only on candle/tile firmware

Final-Hawk commented 3 years ago

To add to the flashing issue, so we are on the same page. Does it look like this?

https://user-images.githubusercontent.com/63589370/122689264-b75fbf00-d264-11eb-9e67-295595bde3c7.mp4

Also to stop the effects on the tiles, this is what i use. (although with a matcher) Just remember to change the IP address

  stop_effect:
    url: 'http://192.168.1.84:6100/v1/lifx/command'
    method: "put"
    payload: '{"command":"effects/stop"}'
    verify_ssl: false
  stop_animation:
    url: 'http://192.168.1.84:6100/v1/lifx/command'
    method: "put"
    payload: '{"command":"animation/stop"}'
    verify_ssl: false

Stop animation stops the animations in photons, like pacman etc. The stop effect one stops the built in firmware effect. If you run both of those before you start the pacman or other animations it should work.

Kackerlacka commented 3 years ago

Yes, that's exactly what my Tiles were doing, and you're right, stopping effects and animations worked like a charm and I can now call the Pac Man animation from Home Assistant! Yay!

So essentially the firmware engineers coded those flame and morph effects into the Tiles and Candle Color, but Photons doesn't use "firmware effects" so to speak for its animations, it just really quickly moves static scenes to create the illusion of animation?

Whether or not that's the case, wouldn't it technically be possible to re-create the flame effect as a Photons Animation but in different colors?

delfick commented 3 years ago

Yes, that's exactly what my Tiles were doing, and you're right, stopping effects and animations worked like a charm and I can now call the Pac Man animation from Home Assistant! Yay!

wooh! Thanks for helping with that @Final-Hawk

for its animations, it just really quickly moves static scenes to create the illusion of animation?

Correct. It updates every pixel on the tiles every 0.075 seconds. The physical limitations of WIFI means I can't go much faster and I don't think that refresh rate is enough for a flame. I could be wrong there, but I also don't have the Maths skillz to implement that effect anyway.

Kackerlacka commented 3 years ago

Correct. It updates every pixel on the tiles every 0.075 seconds. The physical limitations of WIFI means I can't go much faster and I don't think that refresh rate is enough for a flame. I could be wrong there, but I also don't have the Maths skillz to implement that effect anyway.

So from what I understand, Photons sends a constant stream of data through LAN to the Tiles in order to update them at that 0.075 second rate, but the limitations of Wi-Fi prevent us from re-creating something like the Flame Effect as it would need to update quicker than 0.075s. Does that mean that when I normally call the Flame or Morph effects from my HTTP API Rest Commands in Home Assistant, it's still sending a constant stream of data to the Tiles, where the data isn't instructions for updating the zones every 0.075s, but rather instructions to call the firmware effects, and the updating is happening internally, allowing the refresh rate to be bounded not by limitations of Wi-Fi, but hardware/firmware limitations?

delfick commented 3 years ago

The firmware effects are happening in firmware whereas photons animations (and most effects in the app) are a stream of instructions.

So for flame, I send one command to say start flame and then the device doesn't need any further external input to keep doing that.

Whereas with the animation, the device itself has no concept of the animation.

On Mon, 21 Jun 2021, 8:43 am Kackerlacka, @.***> wrote:

Correct. It updates every pixel on the tiles every 0.075 seconds. The physical limitations of WIFI means I can't go much faster and I don't think that refresh rate is enough for a flame. I could be wrong there, but I also don't have the Maths skillz to implement that effect anyway.

So from what I understand, Photons sends a constant stream of data through LAN to the Tiles in order to update them at that 0.075 second rate, but the limitations of Wi-Fi prevent us from re-creating something like the Flame Effect as it would need to update quicker than 0.075s. Does that mean that when I normally call the Flame or Morph effects from my HTTP API Rest Commands in Home Assistant, it's still sending a constant stream of data to the Tiles, where the data isn't instructions for updating the zones every 0.075s, but rather instructions to call the firmware effects, and the updating is happening internally, allowing the refresh rate to be bounded not by limitations of Wi-Fi, but hardware/firmware limitations?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/delfick/photons/issues/61#issuecomment-864621472, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA2V5M5GREHRATYTSDSGWTTTZVK5ANCNFSM467LHNTQ .

Kackerlacka commented 3 years ago

The firmware effects are happening in firmware whereas photons animations (and most effects in the app) are a stream of instructions. So for flame, I send one command to say start flame and then the device doesn't need any further external input to keep doing that. Whereas with the animation, the device itself has no concept of the animation.

Makes perfect sense, thanks for satisfying my curiosity about how all this works.

delfick commented 3 years ago

All good :)

On Mon, 21 Jun 2021, 8:52 am Kackerlacka, @.***> wrote:

The firmware effects are happening in firmware whereas photons animations (and most effects in the app) are a stream of instructions. So for flame, I send one command to say start flame and then the device doesn't need any further external input to keep doing that. Whereas with the animation, the device itself has no concept of the animation. … <#m6528188421854542507> On Mon, 21 Jun 2021, 8:43 am Kackerlacka, @.***> wrote: Correct. It updates every pixel on the tiles every 0.075 seconds. The physical limitations of WIFI means I can't go much faster and I don't think that refresh rate is enough for a flame. I could be wrong there, but I also don't have the Maths skillz to implement that effect anyway. So from what I understand, Photons sends a constant stream of data through LAN to the Tiles in order to update them at that 0.075 second rate, but the limitations of Wi-Fi prevent us from re-creating something like the Flame Effect as it would need to update quicker than 0.075s. Does that mean that when I normally call the Flame or Morph effects from my HTTP API Rest Commands in Home Assistant, it's still sending a constant stream of data to the Tiles, where the data isn't instructions for updating the zones every 0.075s, but rather instructions to call the firmware effects, and the updating is happening internally, allowing the refresh rate to be bounded not by limitations of Wi-Fi, but hardware/firmware limitations? — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#61 (comment) https://github.com/delfick/photons/issues/61#issuecomment-864621472>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA2V5M5GREHRATYTSDSGWTTTZVK5ANCNFSM467LHNTQ .

Makes perfect sense, thanks for satisfying my curiosity about how all this works.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/delfick/photons/issues/61#issuecomment-864622353, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA2V5OZYKV3H34N3MGJ3ILTTZWJTANCNFSM467LHNTQ .

Djelibeybi commented 3 years ago

You can trigger firmware effects using Interactor, though: https://omg.dje.li/2020/03/triggering-lifx-firmware-effects-with-photons-interactor/

I have some examples of using custom palettes for Move and Morph, too.

Kackerlacka commented 3 years ago

Quick question, is it possible to apply the scenes from the LIFX App to the Beam/Z Strip/Candle/Tiles? Scenes like Ghoulish, Intense, Love, Dream, etc... I know I can apply them using the app, then make a scene from their current state using Photons, but I'm trying to find a simple way to "recreate" the randomness that comes from applying those scenes. As I'm sure you're aware, when you apply any of those standard scenes using the LIFX App, the colors are randomly applied throughout the zones of your device so you never get the exact same layout for that scene. Is there a way to recreate this using Photons?

Djelibeybi commented 3 years ago

The colours used by each theme is documented here: https://github.com/wborn/lifx-themes

You can use these palettes to splotch a theme using photons for the same effect as the app.

delfick commented 3 years ago

Yeah, those are themes rather than scenes. So using wborn's repo there you can find the colours and do a

{"command": "apply_theme", "args": {"theme_options": {"colors": ["red", "blue", "green"]}}}
Kackerlacka commented 3 years ago

Yeah, those are themes rather than scenes. So using wborn's repo there you can find the colours and do a

{"command": "apply_theme", "args": {"theme_options": {"colors": ["red", "blue", "green"]}}}

Perfect! Thank you! For some reason I can't seem to get brightness to work, I have

lifx_photons:
  url: 'http://192.168.1.205:6100/v1/lifx/command'
  method: "put"
  payload: '{"command": "animation/start", "brightness": 0.01, "args": {"animations": "{{ states("input_select.photons_animations") }}", "matcher":{"label": "Tiles"} }}'

but regardless of what number I set it to (0.01 to 1), it's always max brightness.

delfick commented 3 years ago

apply_theme has a brightness option, you'd do

  "command": "apply_theme",
  "args": {
    "theme_options": {
      "overrides": {
        "brightness": 0.1
      },
      "colors": [
        "red",
        "blue",
        "green"
      ]
    }
  }
}

There is no one brightness override for an animation. Some animations have options that let you set that, but it's defined per animation. So for example, the dice animation has dice_color, so you could do

{
  "command": "animation/start",
  "args": {
    "animations": [
      [
        "pacman",
        {
          "num_iterations": 1
        }
      ],
      [
        "dice",
        {
          "num_seconds": 5,
          "dice_color": "0-360,1,0.5,3500"
        }
      ]
    ]
  }
}

In that one it does pacman followed by dice followed by pacman followed by dice, etc and the dice are 0.5 brightness.

Pacman has no such options. It's a bit difficult because of how I made it.

Kackerlacka commented 3 years ago

Makes sense regarding the brightness of the animations... I did get the theme brightness to work, but I'm noticing that when I apply a theme to my tiles using Photons, it looks significantly less saturated (or white washed) than the same theme from the app itself. I'm using wborn's repo to apply the hex values to the theme, and I set the saturation to 1, but it's still looking very white to me. Am I applying the saturation correctly? Or is my command wrong somewhere?

lifx_photons_theme_tiles:
  url: 'http://192.168.1.205:6100/v1/lifx/command'
  method: "put"
  payload: '{"command": "apply_theme", "args": {"theme_options": {"colors": {{ states("sensor.lifx_themes") }}, "saturation": 1.0, "kelvin":3500, "overrides": {"brightness": {{ state_attr("light.tiles", "brightness")|float / 255 | round(2) }} } }, "matcher":{"label": "Tiles"} }}'

Here are the hex values I'm applying (Independence day theme): ["hex:#ffffff", "hex:#ff0000", "hex:#0000ff"]

You can see the difference here, where the first one is from Photons and the second is the app itself. The colors seem to be much more blended together and less pronounced in Photons than in the app. I'm assuming I'm doing something wrong with my command, I just don't know what.

20210623_114332

20210623_114350

delfick commented 3 years ago

Yeah, photons uses a different method than the app to work out how to apply the theme and as a result is more blended.

You can play with the colours in the array to give weight to the different colours. So for example

{"colors": ["red saturation:0.5", "blue saturation:0.3", "red", "red", "blue", "blue"]}

Tries to have less white. Or

{"colors": ["red saturation:0.8", "blue saturation:0.8", "red saturation:0.2", "blue saturation:0.2"]}

tries to be more white.

Kackerlacka commented 3 years ago

Makes sense. Quick question, is there a way to not turn on the lights when sending commands to them? It seems whenever I use apply_theme or effects/start it turns on the lights when they're off. I know it's possible to set the state of LIFX devices while keeping them off, as I've been doing it in Home Assistant (I believe it uses LAN protocol too) for a year now.

I have an automation which sets the brightness and color temp of my lights to varying values throughout the day, even when they're off, so that when I do turn them on, they're already the correct brightness/color temp. I would like to extend this to themes as well, but it keeps turning on the lights.

Sorry for all the posts, but you've been an immense help.

delfick commented 3 years ago

So for apply_theme there is {"command": "apply_theme", "args": {"theme_options": {"power_on": false}}} and for effects/run there is {"command": "effects/run", "args": {"matrix_options": {"power_on": false}, "linear_options": {"power_on": false}}}

The animations don't currently have an option for not turning on power when the animation starts.

Sorry for all the posts, but you've been an immense help.

all good :)

There's very little documentation for the specifics of the commands.

Kackerlacka commented 3 years ago

Thanks, this works, except I can't figure out where to put "power_on": false for effects/stop. When I send the effects/stop command to my lights while they're off, they still turn on too. Since there's no "linear_options", "matrix_options", or "theme_options" for effects/stop, I can't figure out where to put "power_on": false in the payload. It seems nowhere that I put it works, the lights always turn on when stopping effects. Any ideas?

delfick commented 3 years ago

ah, it seems that command doesn't have that option. I'd have to add the matrix/linear options that effects/run has. I probably won't have time to do that for a while.

Kackerlacka commented 3 years ago

No problem at all. Just thought I'd make sure there wasn't an option before creating a workaround in Home Assistant. Thanks!

delfick commented 3 years ago

@Kackerlacka with many thanks to @Djelibeybi , if you update photons interactor, it'll have matrix_options and linear_options for effects/stop now :)