delfick / photons

Python3.6+ asyncio framework for interacting with LIFX devices

Home Page:https://photons.delfick.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ignoring power setting when applying a scene/morph effect?

obaldius opened this issue · comments

Hi guys. With the HTTP API from LIFX it's possible to ignore the power settings when applying a scene. How is that achieved when applying a scene with photons? thanks in advanced

  prueba_escena_supervivientes_off:
    url: https://api.lifx.com/v1/scenes/scene_id:e8b0192d-ed38-xxxxxxxxxxxxxxxxxxxxxx
    method: PUT
    headers:
      authorization: Bearer c6ecd1c57dc467562922af25dccf3xxxxxxxxxxxxxxxxxxxxxxxxxx
      accept_encoding: 'gzip, deflate'
    content_type: 'application/json'
    payload:  '{"ignore": ["power"]}'

I cannot get it to work. The scene capture saves the state of the light (on/off) and applies it with the scene_apply. I'd like the scene apply to ignore the saved on/off state, just apply the colors.

{
    "command": "scene_apply",
    "args": {
        "uuid": "08794fff-c604-42ff-b4ed-fcf2094db3ee",
        "overrides": {
            "duration": 1,
            "ignore": ["power"]
        }
    }
}

Can that be done?

I believe it's not working, I tried this, maybe my syntax is wrong? It does apply the scene though. Duration is applied too.

{
    "command": "scene_apply",
    "args": {
        "uuid": "08794fff-c604-42ff-b4ed-fcf2094db3ee",
        "overrides": {
            "duration": 1,
            "power": null
        }
    }
}

Tried this too, ain't working either

"power": "null"

"power": ""

oh I see what's happening. df9875f stops it from letting the null through. I'll figure out an appropriate change when I'm recovered from this cold if no-one else has by then.

On Tue, 3 May 2022, 4:44 pm obaldius, @.> wrote: I believe it's not working, I tried this, maybe my syntax is wrong? { "command": "scene_apply", "args": { "uuid": "08794fff-c604-42ff-b4ed-fcf2094db3ee", "overrides": { "duration": 1, "power": null } } } — Reply to this email directly, view it on GitHub <#108 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA2V5KNFOZFPGZHKXJYTXTVIDDLNANCNFSM5U5XVYUA . You are receiving this because you commented.Message ID: @.>

Oh my such a pity.. I hope you recover soon ^^. Is it the same to apply a scene than applying a transform for every individual light? I could build my scenes transforming each light one by one, ignoring power does work there.. I believe I noticed the scene_apply acts faster though, specially with the tiles.

So scene_apply does this https://github.com/delfick/photons/blob/main/apps/interactor/interactor/commander/commands/scenes.py#L202-L219

Which uses these https://github.com/delfick/photons/blob/main/apps/interactor/interactor/commander/commands/scenes.py#L241-L257

Which uses

It's faster than doing individual interactor commands cause it gets rid of the overhead of making the requests (and there's an existing bug that means http requests to interactor take longer than they should)

So it looks like you either need the scene to have power to null or the overrides to have the power set to null (I imagine the correct fix is to make it so overrides can say "power": "no" given it currently takes out null values from those options)

It seems when you make the scene with scene_capture it doesn't give the ability to override power. But you can use scene_info to get what was captured and feed it back with scene_change to set power to null.

I basically implemented something very basic for scenes and then never actually used those commands or really cared much for them and it shows lol

It seems when you make the scene with scene_capture it doesn't give the ability to override power. But you can use scene_info to get what was captured and feed it back with scene_change to set power to null.

Thanks a lot, I'll do just that. It works!

Ok, now onto the next problem. I'm trying to achieve the same with the morph effect, I managed to run it but I can't find a way to ignore power. I tried the following to no avail:

{
    "command": "effects/run",
    "args": {
        "matcher": {
            "label": "Tiles"
        },
        "matrix_animation": "MORPH",
        "matrix_options": {
            "power": null,
            "speed": 10,
            "palette": [
                "red",
                {
                    "hue": 60,
                    "saturation": 1,
                    "brightness": 1,
                    "kelvin": 3500
                },
                {
                    "hue": 120,
                    "saturation": 1,
                    "brightness": 1,
                    "kelvin": 3500
                },
                {
                    "hue": 180,
                    "saturation": 1,
                    "brightness": 1,
                    "kelvin": 3500
                },
                "purple"
            ]
        }
    }
}

I edited the topic's title to group both issues in the same thread

This ain't working either:

{
    "command": "effects/run",
    "args": {
        "overrides": {
            "power": null
        },
        "matcher": {
            "label": "Tiles"
        },
        "matrix_animation": "MORPH",
        "matrix_options": {
            "speed": 10,
            "palette": [
                "red",
                {
                    "hue": 60,
                    "saturation": 1,
                    "brightness": 1,
                    "kelvin": 3500
                },
                {
                    "hue": 120,
                    "saturation": 1,
                    "brightness": 1,
                    "kelvin": 3500
                },
                {
                    "hue": 180,
                    "saturation": 1,
                    "brightness": 1,
                    "kelvin": 3500
                },
                "purple"
            ]
        }
    }
}

even "overrides": {"power": "off"} won't work

Ok, I found it. I'll leave it here just in case somebody's interested. Note the power_on value.

{
    "command": "effects/run",
    "args": {
        "matcher": {
            "label": "Tiles"
        },
        "matrix_animation": "MORPH",
        "matrix_options": {
            "power_on": false,
            "speed": 10,
            "palette": [
                "red",
                {
                    "hue": 60,
                    "saturation": 1,
                    "brightness": 1,
                    "kelvin": 3500
                },
                {
                    "hue": 120,
                    "saturation": 1,
                    "brightness": 1,
                    "kelvin": 3500
                },
                {
                    "hue": 180,
                    "saturation": 1,
                    "brightness": 1,
                    "kelvin": 3500
                },
                "purple"
            ]
        }
    }
}

yeah, I was a bad engineer for this side project and the external API reflects the internal API, which means there's certainly not enough consistency. Especially for the lack of docs (not something I can fix anytime soon due to how much time I have for photons atm)

In this case the matrix_options are given to https://github.com/delfick/photons/blob/main/modules/photons_control/tile.py#L41 and the linear_options are given to https://github.com/delfick/photons/blob/main/modules/photons_control/multizone.py#L224

yeah, I was a bad engineer for this side project and the external API reflects the internal API, which means there's certainly not enough consistency. Especially for the lack of docs (not something I can fix anytime soon due to how much time I have for photons atm)

In this case the matrix_options are given to https://github.com/delfick/photons/blob/main/modules/photons_control/tile.py#L41 and the linear_options are given to https://github.com/delfick/photons/blob/main/modules/photons_control/multizone.py#L224

I appreciate!

Came back again to thank you for the great work and, maybe not docs, but thanks for the direct support from the developer. I've been relying in the LIFX Cloud for a while and now that I moved everything local it's just worlds worlds better, I love it.

Thanks!

enough said

You're welcome!!