Skip to content

Implement effect support #3034

Open
Open
@bramstroker

Description

We could implement LUT functionality to support effects for lights.
CSV could have 3 columns.

effect, brightness, power

Extend measure tool with ability to measure effects

  • Ask user if he want to measure effects. Might be auto detected if light supports effects.
  • Cycle through all effects, and brightness levels (with step size 10 for example).
  • Record measurement in effects.csv similarly as for the other CSV's

Add support in integration

  • Modify lut.py strategy to check if an effect has been choosen. See if there is some common / robust way to determine this for lights.
  • When effect has been choosen lookup power value, and interpolate, similary as for the color modes lookup.

Extend LUT validator

  • Should validate correct CSV structure

Extend documentation

Activity

bramstroker

bramstroker commented on Jan 31, 2025

@bramstroker
OwnerAuthor

WIP: #3043

challgren

challgren commented on Jan 31, 2025

@challgren
Contributor

As soon as you got something in code a bit more I can help finish it. I'm mainly a PHP and kotlin dev so python is a bit hard for me to get started but I'll be glad to test and help. Also one thing I noticed is if an effect is running. The last color temp/hs is still in the attributes but the effect is not null. So right now I'm getting readings on the last color vs unavailable or unknown. But I know you said that was gonna happen. So we may want to look into not calculating use if an effect is not mapped.

bramstroker

bramstroker commented on Jan 31, 2025

@bramstroker
OwnerAuthor

Thanks.
Yes I'll make sure when the is an effects.csv file the profile will be marked in a is_effect_supported profile. Whenever this is the case, the strategy can lookup the corresponding effect when attribute effect is not null, when the effect is not available in the CSV we can set the power sensor to unavailable.

P.S. I'm also mainly a PHP dev, been doing the for 20+ years, and still professionally.
Also did some C# and lot of JS.
Python now on this side project for 3+ years
It's all just syntax, good programming practices, and software architecture are universal.

bramstroker

bramstroker commented on Feb 1, 2025

@bramstroker
OwnerAuthor

All right, just done development, and PR has been merged to master.

When I was working on the measure tool extensions I also added retry mechanism for light controller: fb747b8.

New docker build has just been done, and published to docker hub.
https://hub.docker.com/layers/bramgerritsen/powercalc-measure/master/images/sha256-45eeb363dab733db59fce9834ed1bfaf306898df84233094d4b0c0fc7578aa72

Could you please try pulling and giving it a test run?
You can select effect now as mode in the wizard.

Let me know how it goes and if you stumble upon any issues.

challgren

challgren commented on Feb 2, 2025

@challgren
Contributor

So here is my first file with the default settings of 10 seconds measuring effect. I'm also taking another measurement with the period being 5 minutes. I'm doing the 5 minute measure as some of the effects are longer than 10 seconds.

effect-10s.csv.gz

bramstroker

bramstroker commented on Feb 2, 2025

@bramstroker
OwnerAuthor

Thanks! cool everything works. Definitely needs some tweaking on measure period. Curious if we get better results with 5 minute period.
I had set to 10 seconds, because I had 189 effects on my WLED test, and that would take 4.5 hours ;-)

There is some strange behaviour especially on lowest brightness level where some effect have a higher consumption than later.

Image

challgren

challgren commented on Feb 3, 2025

@challgren
Contributor

Yeah Im doing a 300 second period right now and was gonna upload the file once its done in 50 hours. Then I was going to run it in 120 second period to compare. I know you got the fancy graphing so its helpful to see it visually.

bramstroker

bramstroker commented on Feb 3, 2025

@bramstroker
OwnerAuthor

Fancy graphs are in utils/visualize btw.
You can run poetry install --no-root from that directory.
And then poetry run python plot.py myfile.csv
In playground directory there is also an example using plotly.

challgren

challgren commented on Feb 5, 2025

@challgren
Contributor

Some 56 hours later here is my measure of the effects running for 300 (5 minutes). I am still seeing that initial high measurement on the lower brightnesses.

Will be reporting back tomorrow with a 60 second run.

Image

effect-300s.csv.gz

challgren

challgren commented on Feb 5, 2025

@challgren
Contributor

So here is the 60 second measure results. With the same brightness issue.

Image

effect.csv.gz

bramstroker

bramstroker commented on Feb 7, 2025

@bramstroker
OwnerAuthor

Interesting patterns and results.
Very strange the behaviour at low brightness level. I would almost expect that the effect is turning on at full brightness.
Measure tool starts at brightness 5.
Could you try manually using the light.turn_on action and set brightness to 5 and effect to moonlight for example and see what happens?

Besides the bug on lowest brightness level both graphs look quite comparable.

There are two effects having a bit strange pattern on the 5 minute chart. lowest green line which drops after 70.
And blue line which have some spikes down.

In the 60 second chart one effect stands out, the one with the olive color. Do you know which effect that is?

Also the 10 second chart I shared previously looks quite similar to these two charts.
So I would say 5 minute would be overkill and we should pick a value between 10 and 60 second. 30 seconds feels like a good compromise to me. Where measure session would not take forever, and we get reliable enough results to do a good approximation.

14 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Implement effect support · Issue #3034 · bramstroker/homeassistant-powercalc