steveredden / homebridge-kasa-lightstrip

A homebridge plugin for controlling Kasa Light Strips :zap:
MIT License
2 stars 1 forks source link

Issues with Custom Effects #3

Closed thuelskamp closed 2 years ago

thuelskamp commented 2 years ago

First off, thank you for the great plugin!

I'm having issues with some custom effects. Some work, some do not if you change any parameter (using only the brightness parameter in these examples). This varies between effects so I'm including two that I've tried setting up multiple ways with one (Ocean) that always works after any modification from within the Kasa app, and the other (Flicker) which doesn't work (lights just flash like crazy at 100% brightness) if anything is modified within the Kasa app.

Examples:

Ocean effect seems to work no matter what. Here is the custom effect JSON after setting Ocean to 15% brightness within the Kasa app (default brightness for Ocean effect is 30 which works as intended):

{'custom':0,'id':'oJjUMosgEMrdumfPANKbkFmBcAdEQsPy','brightness':15,'name':'Ocean','segments':[0],'expansion_strategy':1,'enable':1,'type':'sequence','duration':0,'transition':2000,'direction':3,'spread':16,'repeat_times':0,'sequence':[[198,84,30],[198,70,30],[198,10,30]]}

Flicker effect without any modification (works fine)

{'custom':0,'id':'bCTItKETDFfrKANolgldxfgOakaarARs','brightness':100,'name':'Flicker','segments':[1],'expansion_strategy':1,'enable':1,'type':'random','hue_range':[30,40],'saturation_range':[100,100],'brightness_range':[50,100],'duration':0,'transition':0,'transition_range':[375,500],'init_states':[[30,81,80]]}

Flicker effect after adjusting brightness to 20 (breaks the effect which results in the light strip flashing like crazy at 100% brightness. This is the same behavior for any effect which breaks).

{'custom':0,'id':'bCTItKETDFfrKANolgldxfgOakaarARs','brightness':20,'name':'Flicker','segments':[1],'expansion_strategy':1,'enable':1,'type':'random','hue_range':[30,40],'saturation_range':[100,100],'brightness_range':[50,100],'duration':0,'transition':0,'transition_range':[375,500],'init_states':[[30,81,80]]}

steveredden commented 2 years ago

I don't claim to be any expert on the way they've structured their lighting effects... but my first thought is you're setting a brightness outside of your range...

'brightness': 20,
'brightness_range': [50,100],

I'd guess you'd want to change the 50 to a 20, or maybe remove the key altogether. Or add the 20?

Again: I have no idea what schema they're expecting at this point.

I'd also recommend building the effects inside the app and exporting the json... seems like you'd get 'in bounds' data if you do it within the app

thuelskamp commented 2 years ago

Good call on the brightness range. Replacing the 50 with 20 worked for this particular effect (I'll test others later). What's interesting is that effect was built inside the app.

I just tested and see that if I turn on the flicker effect (default brightness 100) from the app then use: "kasa --host "yourIP" --lightstrip raw-command smartlife.iot.lighting_effect get_lighting_effect | sed "s/ //g""

The output: {'custom':0,'id':'bCTItKETDFfrKANolgldxfgOakaarARs','brightness':100,'name':'Flicker','segments':[1],'expansion_strategy':1,'enable':1,'type':'random','hue_range':[30,40],'saturation_range':[100,100],'brightness_range':[50,100],'duration':0,'transition':0,'transition_range':[375,500],'init_states':[[30,81,80]]}

Then adjusting the brightness of the flicker effect down to 20 within the Kasa app, run the raw command, it outputs: {'custom':0,'id':'bCTItKETDFfrKANolgldxfgOakaarARs','brightness':20,'name':'Flicker','segments':[1],'expansion_strategy':1,'enable':1,'type':'random','hue_range':[30,40],'saturation_range':[100,100],'brightness_range':[50,100],'duration':0,'transition':0,'transition_range':[375,500],'init_states':[[30,81,80]]}

So it seems like some effects are not adjusting the brightness range. I have no idea how their effects are structured either and it's beyond my level of understanding frankly. At least I know now how to manually fix brightness ranges it seems. Thank you for that.

steveredden commented 2 years ago

Interesting indeed!

I could envision a separate script to validate custom input (ensure brightness is included or within brightness_range, etc).

There's not a great place to inject such guardrails in the main code stream.

I'll close for now, but let me know if you find any other configurations (and solutions) that produce strange effects!