machgo / fellerwiserhomeassistant

Integration to support Feller Wiser in HomeAssistant
21 stars 8 forks source link

Update light.py (using ctrl) #8

Closed kess78 closed 2 months ago

kess78 commented 3 months ago

Changed to ctrl endpoint to simulate a button click instead of hardcoding value for on/off to 0/100 for lights

machgo commented 2 months ago

We can't use this because its breaking dimming the lights. The method turn_on is also called when you try to dim the lights with homeassistant. But maybe we can filter the incoming event in the turn_on method and then handle the api call differently based on the call:

I haven't looked into it yet, but maybe someone else knows if this is possible? 🧐

tech-geek-4 commented 2 months ago
  • light is turned on in homeassistant -> emulate click
  • light is dimmed in homeassistant -> set brightness

I tried almost what you suggested but i think it didn‘t worked due to my limited Python skills (learning it right now… 😉). But i would suggest the following:

That way you could use it irrespectively of the light type and the light always starts at the last brightness.

EDIT: This might screw up starting the light with the slider but not sure…

machgo commented 2 months ago

I've tried to store the old brightness and restore it on the next turn_on. 3f07e8d158d7add014da5e60fb65a3dc6bcd2501 Works fine for me, but lets wait on the feedback of the other users 😉

tech-geek-4 commented 2 months ago

Sorry put another pull request the same time you published yours.

I will try your code as well and let you know in the evening. Maybe you find a second to have a look at mine.

tech-geek-4 commented 2 months ago

I've tried to store the old brightness and restore it on the next turn_on. 3f07e8d Works fine for me, but lets wait on the feedback of the other users 😉

EDIT: Works for me as well! Thanks!

tech-geek-4 commented 2 months ago

I‘m sorry but disregard… 🤦‍♂️ It doesn‘t work completely.

When i have the lamp for example at 50% and dim it down with the physical switch to let‘s say 25% that is shown correctly in HA. When i switch it off now with the physical button. It turns off. When i turn it on with HA it then goes back to 50%. I assuem because of the fact, that when turning it of manually the „oldbrightness“ value is not stored.

I try the how it works with my code an let you know in this PR

kess78 commented 2 months ago

In my opinion it would be better to let manage the last brightness value on the uGateway instead of storing it in HA. The integration should only read from uGateway. On and Off should be done with ctrl endpoint, and dim with target_state endpoint.

As soon as I receive my test device I'll try to look into it...

Thx for your patience.

tech-geek-4 commented 2 months ago

In my opinion it would be better to let manage the last brightness value on the uGateway instead of storing it in HA.

I thought the same. That's why i merged your code with mine to #10. Works without an error for me since yesterday. Looking forward for your thoughts about it next week. Enjoy sunny sunday!