OpenBK7231T_App icon indicating copy to clipboard operation
OpenBK7231T_App copied to clipboard

automatically turn off the bulb when brightness is below 1, turn on w…

Open Refuhr opened this issue 2 years ago • 14 comments

…hen above 1 I really liked the feature in Tasmota and thought it would be practical here as well. What do you think of this implementation and do you even want this feature?

Refuhr avatar Sep 26 '22 19:09 Refuhr

Idea is good, but it seems you are doing it incorrectly. You are just setting g_led_enableAll to 0, but you do not broadcast it's change over MQTT. Is this intended?

openshwprojects avatar Sep 28 '22 08:09 openshwprojects

It wasn't intended, missed that one. I think I got it working now by running the "LED_SendEnableAllState()" function.

Refuhr avatar Sep 28 '22 09:09 Refuhr

Hmm it seems better. Do you think this behaviour should be always on, or will we add a flag for that? With CFG_HasFlag or whatever it was called....

openshwprojects avatar Sep 28 '22 17:09 openshwprojects

I would add a flag, I even have some code for that already. It includes turning on when the temperature/color changes.

Refuhr avatar Sep 28 '22 18:09 Refuhr

I now added a flag "[LED] always turn on bulb when color changes" (OBK_FLAG_LED_ON_CHANGE_TURN_ON) that when checked turns the lamp on when: color/temperature/brightness is changed. One feature I put on at default is turning the lamp off when brightness is 0 and once the brightness is above 0 turning the lamp on once. So it wouldn't turn on when changing the brightness from 20 to 30 for example (Can also be changed, but I thought it made sense. + HA only sets the brightness to 1 at minimum, so it wouldn't trigger turning it off.).

Refuhr avatar Sep 28 '22 19:09 Refuhr

I might have destroyed your indentation, working on it.

Refuhr avatar Sep 28 '22 19:09 Refuhr

Current version doesn't seem to build?

openshwprojects avatar Sep 29 '22 17:09 openshwprojects

Don't know what happened there, I reset to an older commit.

Refuhr avatar Oct 01 '22 13:10 Refuhr

There are still some things that are needed to be fixed. https://github.com/openshwprojects/OpenBK7231T_App/pull/216/commits/8789093124512df8cdf38f833e6ce2cb9dfe74bc In this commit, you are using "char * last_led_color = "#ffffff";" and trying to compare it with given args string "c != last_led_color &&", but it will never work correctly because in C language you are just comparing the pointer values that way (addresses in the memory). Futhermore, you are not writing to "last_led_color " so I think that "last_led_color " can be removed.

openshwprojects avatar Oct 03 '22 06:10 openshwprojects

Removed last_led_color and the check. Tested and seems to be working.

Refuhr avatar Oct 04 '22 11:10 Refuhr

I now updated my branch to the newest and implemented it again. To conclude: I added a flag ([LED] always turn on bulb when color changes), which always turns on the bulb when there is any state change (color/temperature/brightness). When the flag is turned off, the light turns only off when the brightness is below 1 and only turns on once when the last brightness is 0 and the current is above 0. I tested again with my lamp and everything seems to be working.

Refuhr avatar Oct 05 '22 10:10 Refuhr

I'll recheck this tomorrow and most likely merge it then. Thanks

openshwprojects avatar Oct 05 '22 11:10 openshwprojects

I am not sure if the "basecolor" command can turn on the led. Can Home Assistant send a "basecolor" command to bulbs on reboot, even if they are turned off?

openshwprojects avatar Oct 09 '22 11:10 openshwprojects

For me, when the lights are turned off, I am only able to either change the brightness or use the on/off switch. The other controls are not even showed. Maybe it is somehow possible, I'll look into that.

Refuhr avatar Oct 09 '22 21:10 Refuhr

Tasmota has this on as a default since it makes logical sense but you can disable the auto on to do things like change the color of a light without turning it on so it will be set when you do turn it on, like if you have lights simulate sunrise or go cooler temp during the day then warm at night.

https://tasmota.github.io/docs/Lights/#disable-auto-power-on

For me, when the lights are turned off, I am only able to either change the brightness or use the on/off switch. The other controls are not even showed. Maybe it is somehow possible, I'll look into that.

Home assistant is limited in it's default cards for lights like that. but you can do it in the webui for tasmota or mqtt/etc.

beren12 avatar Jan 03 '23 17:01 beren12