delfick / photons

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

Photons for Home Assistant #61

Closed Kackerlacka closed 3 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.

Djelibeybi commented 3 years ago

The json would be:


{
    "command": "effects/stop",
    "args": {
        "stop_matrix": true,
        "matrix_options": {
             "power_on": false
        },
        "stop_linear": true,
        "linear_options": {
            "power_on": false
        }
    }
}
Kackerlacka commented 3 years ago

Wow that was fast, thanks so much for taking the time to implement that! One question, do you have to release a new version of the Home Assistant Photons add-on each time you update Photons? Because I switched over to the Photons Add-On instead of using Portainer, and I'm not sure how that works. Thanks.

Final-Hawk commented 3 years ago

Updating the addon is fairly simple. To force homeassistant to check for addon updates, click on the addon store then the 3 dots. Under there is reload. After it has reloaded, the photons addon should show the menu to update it

Kackerlacka commented 3 years ago

Ah yep that did it. I figured it was always automatic but I suppose sometimes you have to reload it. Thanks for the help!

delfick commented 3 years ago

yeah, I told it about the new version https://github.com/delfick/photons-homeassistant/commit/7dd675c779d627eee5349d7e4ad82506a5fc60c9

On Sun, 27 Jun 2021, 6:57 pm Kackerlacka, @.***> wrote:

Ah yep that did it. I figured it was always automatic but I suppose sometimes you have to reload it. Thanks for the help!

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

Kackerlacka commented 3 years ago

So I updated my Photons Interactor to 0.8.7, but when I input the following command, it does in fact stop the animation while my Beam/Tiles are off, but it turns them on in the process still.

photons_effects_stop:
  url: 'http://192.168.1.205:6100/v1/lifx/command'
  method: "put"
  payload: '{"command": "effects/stop", "args": {"matcher": {"label": {{ label }} }}, "stop_matrix": true, "matrix_options": {"power_on": false}, "stop_linear": true, "linear_options": {"power_on": false} }'

Is there something I did wrong in this command?

delfick commented 3 years ago

Maybe it didn't get restarted?

What does {"command": "help", "args": {"command": "effects/stop"}} show?

It should have linear_options and matrix_options there. (annoyingly I did just notice it has theme options which it shouldn't, I'll remove that another day, those do nothing to this command)

delfick commented 3 years ago

Oh, I see the problem

You have this

  "command": "effects/stop",
  "args": {
    "matcher": {
      "label": "label"
    }
  },
  "stop_matrix": true,
  "matrix_options": {
    "power_on": false
  },
  "stop_linear": true,
  "linear_options": {
    "power_on": false
  }
}

instead of

{
  "command": "effects/stop",
  "args": {
    "matcher": {
      "label": "label"
    },
    "stop_matrix": true,
    "matrix_options": {
      "power_on": false
    },
    "stop_linear": true,
    "linear_options": {
      "power_on": false
    }
  }
}
Djelibeybi commented 3 years ago

@delfick 's formatting doesn't make it obvious but the stop_matrix and matrix_options fields must be inside the "args": {} block, e.g.

{
  "command": "effects/stop",
  "args": {
    "matcher": {
      "label": "label"
    },
    "stop_matrix": true,
    "stop_linear": true,
    "matrix_options": {
      "power_on": false
    },
    "linear_options": {
      "power_on": false
    }
  }
}
Kackerlacka commented 3 years ago

So I changed my REST command to this, with all the arguments inside the "args" block, but it's still turning on the lights when they're off.

photons_effects_stop:
  url: 'http://192.168.1.205:6100/v1/lifx/command'
  method: "put"
  payload: '{"command": "effects/stop", "args": {"matcher": {"label": {{ label }} }, "stop_matrix": true, "matrix_options": {"power_on": false}, "stop_linear": true, "linear_options": {"power_on": false} }}'

The command {"command": "help", "args": {"command": "effects/stop"}} does show stop_linear and stop_matrix, but it does not show power_on (then again using the help command doesn't show power_on for any commands anyway)

Also it looks like stop_linear and stop_matrix default to true so I probably don't need them in there at all for what I'm doing... nevertheless just having "power_on": false doesn't seem to work.

I did restart Home Assistant, the Photons Add-On, and I tried the commands in the Terminal as well, it doesn't seem to work for me.

Djelibeybi commented 3 years ago

Does {"command": "help", "args": {"command": "effects/stop"}} show matrix_options and linear_options? That's what' we're looking for. The output of an updated client should end with this:

stop_matrix: boolean (default True)
    Whether to stop any matrix animations

matrix_options: dictionary
    Any options to give when stopping to the matrix animation. For example power_on

stop_linear: boolean (default True)
    Whether to stop any linear animations

linear_options: dictionary
    Any options to give when stopping the linear animation. For example power_on

If you don't see those two options then the Photons container hasn't been upgraded properly.

Kackerlacka commented 3 years ago

I only see the following:

Screenshot 2021-06-27 171040

This is the current version of my Photons Interactor: Screenshot 2021-06-27 171236

Final-Hawk commented 3 years ago

I wonder if it's not updating correctly. Have you done a full system restart? What does portainer show under images?

Djelibeybi commented 3 years ago

I've just tested delfick/lifx-photons-interactor-homeassistant:0.8.7 and it is returning the updated text. Can you run docker images and docker ps -a in your hass.io shell (or wherever the docker images live)?

Kackerlacka commented 3 years ago

I wonder if it's not updating correctly. Have you done a full system restart? What does portainer show under images?

I switched from Portainer to the Photons Interactor Add-On, and I have fully restarted Home Assistant as well as the Photons Interactor Add-On itself. I just did it again, same result. Honestly I have zero experience with any command line commands in Home Assistant so I have no idea how to run those docker commands.

One potentially interesting thing I noticed is that in the Changelog for 0.8.6, it says that help messages were added for the apply_theme option. But since I've been using the Photons Interactor Add-On, it's always given me this error: Screenshot 2021-06-27 174139

Djelibeybi commented 3 years ago

This works for me using using Interactor 0.8.7: {"command": "help", "args": { "command": "apply_theme" }}

Whoops, I misread your post. Can we see the the output from docker inspect on the running Photons Interactor container perhaps? It's been a while since I ran Home Assistant, so I can't remember how to get container debug info.

Kackerlacka commented 3 years ago

I may be wrong, but I don't think there's actually a way to run docker commands in Home Assistant (at least not using HassOS like I am). So I'm not sure what I can do to help.

I tried uninstalling Photons Add-On and reinstalling it using Portainer (as described above) but now I'm getting an error 502: Bad Gateway error with Portainer, and the Photons Add-On won't start anymore because "Errno 98: Address already in use"

The Photons Add-On isn't running and Portainer is uninstalled but I can still send commands no problem...

Final-Hawk commented 3 years ago

Open up portainer and under the containers tab, remove all images that are called something like photons interactor. Then reinstall the addon. Hopefully that does it.

Kackerlacka commented 3 years ago

So it looks like when I uninstalled Portainer and the Photons Interactor Container (after you released the HA Add-On), somehow I guess the container didn't get uninstalled, so I had been running that the whole time without Portainer installed, thinking that it was the Add-On. That's why it was updated to 0.8.7 and still not working - it was using the Docker Image installed from Portainer.

Anyway, thank you all for being so patient. I'm happy to say that after (re-)uninstalling the Interactor and Portainer and reinstalling the Add-On, 0.8.7 is working perfectly. Thanks so much!

pimw1 commented 3 years ago

Hi all, scene_capture followed by scene_apply is not working for the candle: it just applies one and the same color for the whole bulb.

Is there any way i can capture->apply the individual zones ? Or any way to individually define the different zones by hand?

delfick commented 3 years ago

weird. It should work. Can you do a discover command and a scene_info command and put them in a gist so I can have a look? Maybe it doesn't think your candle is a candle for some reason.

I'd try it out myself but I have a new laptop and I'm unlikely to have it setup this weekend.

pimw1 commented 3 years ago

I've done a discover and scene_info but I've never put anything in a gist, so i'll copy-paste the relevant stuff here (some identifiers are anonymised). I'm not sure if it is relevant, but i also have 4 Lifx Mini Color bulbs, one Lifx A19 and 2 Lifx Z LED Strips. These are removed from the overview below.

discover:

"d073d5xxxxxx": {
        "brightness": 1.0,
        "cap": [
            "color",
            "matrix",
            "not_buttons",
            "not_chain",
            "not_hev",
            "not_ir",
            "not_multizone",
            "not_relays",
            "variable_color_temp"
        ],
        "firmware_version": "3.50",
        "group_id": "aaaaaaaaaaaaaaaaaa",
        "group_name": "Balkon",
        "hue": 0.0,
        "kelvin": 3500,
        "label": "Kandelaar 2",
        "location_id": "bbbbbbbbbbb",
        "location_name": "Thuis",
        "power": "on",
        "product_id": 57,
        "saturation": 1.0,
        "serial": "d073d5xxxxxx"
    },
    "d073d5yyyyyy": {
        "brightness": 1.0,
        "cap": [
            "color",
            "matrix",
            "not_buttons",
            "not_chain",
            "not_hev",
            "not_ir",
            "not_multizone",
            "not_relays",
            "variable_color_temp"
        ],
        "firmware_version": "3.50",
        "group_id": "aaaaaaaaaaaaaaaaaa",
        "group_name": "Balkon",
        "hue": 19.29,
        "kelvin": 3500,
        "label": "Kandelaar 1",
        "location_id": "bbbbbbbbbbb",
        "location_name": "Thuis",
        "power": "on",
        "product_id": 57,
        "saturation": 0.9988,
        "serial": "d073d5yyyyyy"

scene_info:

 "14c387ba-d037-404d-9bba-33fd1b1b2382": {
        "meta": {
            "uuid": "14c387ba-d037-404d-9bba-33fd1b1b2382"
        },
        "scene": [

            {
                "color": "kelvin:3500 saturation:1.0 brightness:0.2129 hue:3.0",
                "matcher": {
                    "serial": "d073d5xxxxxx"
                },
                "power": true,
                "uuid": "80863b36-bafc-4556-a399-4e5832f5274a"
            },
            {
                "color": "kelvin:3500 saturation:1.0 brightness:0.2135 hue:0.0",
                "matcher": {
                    "serial": "d073d5yyyyyy"
                },
                "power": true,
                "uuid": "80863b36-bafc-4556-a399-4e5832f5274a"
            }
        ]
    },
    "835b0bd1-b97f-4d79-b1b0-48eadfeb0431": {
        "meta": {
            "uuid": "835b0bd1-b97f-4d79-b1b0-48eadfeb0431"
        },
        "scene": [

            {
                "color": "kelvin:3500 saturation:1.0 brightness:0.2129 hue:3.0",
                "matcher": {
                    "serial": "d073d5xxxxxx"
                },
                "power": true,
                "uuid": "835b0bd1-b97f-4d79-b1b0-48eadfeb0431"
            },
            {
                "color": "kelvin:3500 saturation:1.0 brightness:0.2135 hue:0.0",
                "matcher": {
                    "serial": "d073d5yyyyyy"
                },
                "power": true,
                "uuid": "835b0bd1-b97f-4d79-b1b0-48eadfeb0431"
            }
        ]
    }
pimw1 commented 3 years ago

Hi all, scene_capture followed by scene_apply is not working for the candle: it just applies one and the same color for the whole bulb.

Is there any way i can capture->apply the individual zones ? Or any way to individually define the different zones by hand?

By the way, i've solved this in a different way:

  1. In Home Assistant, add the Photons Interactor Repository https://github.com/delfick/photons-homeassistant. Install Photons Interactor. Run it.
  2. Set the desired scene via the Lifx Android app
  3. Run the following command to retrieve the matrix settings for that scene:
curl -XPUT http://your_ip_address:6100/v1/lifx/command \
  -HContent-Type:application/json \
  -d '{
  "command": "query",
  "args": {
    "matcher": {
      "cap": "matrix"
    },
    "pkt_type": "Get64",
    "pkt_args": {
      "length": 1,
      "tile_index": 0,
      "width": 5,

      "x": 0,
      "y": 0

    }
  }
}'
  1. Copy the output and execute the below command (replace the matrix values with the output from step 2). Please be aware that the "serial" is the mac-address of your device in lower case and without the ":" signs. Make sure that it works, before proceeding to step 5.

    curl -XPUT http://your_ip_address:6100/v1/lifx/command \
    -HContent-Type:application/json \
    -d '{
    "command": "set",
    "args": {
    "matcher": {
      "serial":"d073d5xxxxxx"
    },
    "pkt_type": "Set64",
    "pkt_args": {
      "length": 1,
      "tile_index": 0,
      "width": 5,
      "colors_count": 2,
      "x": 0,
      "y": 0,
      "duration": 2,
      "colors": [
                    {
                        "brightness": 0.2135,
                        "hue": 0.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 0.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 121.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 121.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 121.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 0.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 0.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 0.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 0.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 0.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 0.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 0.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 0.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 0.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 0.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 270.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 270.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 238.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 238.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 238.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 270.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 270.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 238.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 238.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 238.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    }
      ]
    }
    }
    }'
  2. In Home Assistant, add the following to Configuration.yaml

    rest_command:
    your_command_name:
    url: 'http://127.0.0.1:6100/v1/lifx/command'
    method: "put"
    payload: |
      {
      "command": "set",
      "args": {
        "matcher": {
          "serial":"d073d5xxxxxx"
        },
        "pkt_type": "Set64",
        "pkt_args": {
          "length": 1,
          "tile_index": 0,
          "width": 5,
          "colors_count": 2,
          "x": 0,
          "y": 0,
          "duration": 2,
          "colors": [
                    {
                        "brightness": 0.2135,
                        "hue": 0.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 0.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 121.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 121.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 121.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 0.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 0.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 0.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 0.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 0.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 0.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 0.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 0.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 0.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 0.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 270.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 270.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 238.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 238.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 238.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 270.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 270.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 238.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 238.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.2135,
                        "hue": 238.0,
                        "kelvin": 3500,
                        "saturation": 1.0
                    },
                    {
                        "brightness": 0.0,
                        "hue": 0.0,
                        "kelvin": 3500,
                        "saturation": 0.0
                    },
                    {
                        "brightness": 0.0,
                        "hue": 0.0,
                        "kelvin": 3500,
                        "saturation": 0.0
                    },
                    {
                        "brightness": 0.0,
                        "hue": 0.0,
                        "kelvin": 3500,
                        "saturation": 0.0
                    },
                    {
                        "brightness": 0.0,
                        "hue": 0.0,
                        "kelvin": 3500,
                        "saturation": 0.0
                    },
                    {
                        "brightness": 0.0,
                        "hue": 0.0,
                        "kelvin": 3500,
                        "saturation": 0.0
                    }
                    ]
                    }
              }
      }
  3. Reboot Home Assistant (that is why you have to make sure that step 4 is working: you don't want to reboot Home Assistant every time while debugging. Debugging should be done in step 4).

  4. Within Home Assistant, you can use your command as a service (rest_command.your_command_name)

Three things that I noticed:

delfick commented 3 years ago

yeah, a Set64 will definitely do it. Strange that scene_capture isn't recording that. It does have the matrix capability. I'll have a look when I'm back up and running.

For the hsbk and duration, that's because Photons performs transformations: https://github.com/delfick/photons/blob/main/modules/photons_messages/fields.py#L29-L47

pimw1 commented 3 years ago

Hi Delfick, i've waited for the outcome of your research, once you are/were up&running again. I see that you just closed in the incident. Could you explain your line of thinking?

delfick commented 3 years ago

ah yes, the candle, I'll look at that now and move that into a new issue - https://github.com/delfick/photons/issues/70

Kackerlacka commented 2 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.

Not trying to revive this thread or anything but I wanted to try out setting individual LEDs' colors (so I can make my own pictures) on my Tiles using this command, but whenever I try it I just get this back in the console and nothing changes on my tiles, any advice?

# curl -XPUT http://127.0.0.1:6100/v1/lifx/command -HContent-Type:application/js
on -d '{"command": "set", "args": {"matcher": {"cap": "Tiles2"}, "pkt_type": "Se
t64", "pkt_args": {"length": 2, "tile_index": 0, "width": 8, "colors_count": 1,
"x": 5, "y": 0, "color": {"hue": 400, "brightness": 1, "saturation": 1, "kelvin"
: 3500} }}}'
{
    "results": {}
}

Edit: I realized the "cap" should be "label", but even doing that returns this:

    "results": {
        "d073d5527d0a": "ok"
    }

Setting the colors to {"hue": 400, "brightness": 1, "saturation": 1, "kelvin" : 3500} changes an individual LED, but using "green", or "red" does nothing. Do I have to define every LED as a hue, brightness, saturation, and kelvin? Or is there a way to simply say "red" like I've tried?

delfick commented 2 years ago

I don't have any tiles setup to test with and they're a pain to bring out from where they are, but I believe the problem is you need to send colors instead of color in that message and make sure colors_count is set to the number of colours you want.

Also, for sending the packet type itself, you do need to give them as hsbk dictionaries. We'd need to add a command for setting pixels that knows how to convert friendlier names into those hsbk dictionaries

Kackerlacka commented 2 years ago

I don't have any tiles setup to test with and they're a pain to bring out from where they are, but I believe the problem is you need to send colors instead of color in that message and make sure colors_count is set to the number of colours you want.

Also, for sending the packet type itself, you do need to give them as hsbk dictionaries. We'd need to add a command for setting pixels that knows how to convert friendlier names into those hsbk dictionaries

HSBK dictionaries is ok, I can deal with that. As for the color vs colors.... I guess I'm not understanding what this command does. I'm trying to have this command set the color of 1 single LED, but it looks like if I set colors to HSBK values it makes 2 LEDs that color, and 3 makes 3 LEDs that color, etc. But if I put one HSBK value and change colors to color it returns ok but doesn't seem to do anything. If I send 1 HSBK value with colors instead of color it give me an error.

Basically all I'm trying to do is understand how this command works so I can create any "image on my tiles that I want. Would you be able to send an example command for how to set the tile LEDs to make a smiley face? Or a square around the perimeter of the tiles? Or any example so I can adapt it to what I want to do? Thanks in advance!

delfick commented 2 years ago

the Set64 takes in colors as a list of dictionaries. so when you don't specify it photons is defaulting to an empty list

there is no color on a Set64 and so photons is ignoring your provided color option

I missed before it seems this message in the lifx protocol doesn't have a colors_count. It will set all 64 pixels. So colors_count is also being ignored and photons will default to hsbk:0,0,0,0 for the pixels you don't define.

So basically to change only one pixel you have to know all current pixels and send them all again but with that one different pixel

the full docs for Set64 are over here: https://lan.developer.lifx.com/docs/changing-a-device#set64---packet-715

On Mon, 14 Feb 2022, 8:03 pm Kackerlacka, @.***> wrote:

I don't have any tiles setup to test with and they're a pain to bring out from where they are, but I believe the problem is you need to send colors instead of color in that message https://photons.delfick.com/interacting/packets.html?highlight=set64#tilemessages-set64 and make sure colors_count is set to the number of colours you want.

Also, for sending the packet type itself, you do need to give them as hsbk dictionaries. We'd need to add a command for setting pixels that knows how to convert friendlier names into those hsbk dictionaries

HSBK dictionaries is ok, I can deal with that. As for the color vs colors.... I guess I'm not understanding what this command does. I'm trying to have this command set the color of 1 single LED, but it looks like if I set colors to HSBK values it makes 2 LEDs that color, and 3 makes 3 LEDs that color, etc. But if I put one HSBK value and change colors to color it returns ok but doesn't seem to do anything. If I send 1 HSBK value with colors instead of color it give me an error

— Reply to this email directly, view it on GitHub https://github.com/delfick/photons/issues/61#issuecomment-1038824843, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA2V5L7Q3EMQDBCS6JV5ZDU3DAOTANCNFSM467LHNTQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you modified the open/close state.Message ID: @.***>