machgo / fellerwiserhomeassistant

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

Dimmer Light always 100% when turning on by "button" #7

Closed tech-geek-4 closed 1 month ago

tech-geek-4 commented 2 months ago

Dear Marco,

First, please let me thank you very much for your integration and your support. It works absolutely great. Since i found this integration a month ago i threw almost all of my rest command coding out of my configuration.yaml! :smirk: (except for the awnings which have to be more or less 180 degree different - but this is another HA Topic... :wink:)

Concerning my issue: I realised, that when i turn on the light of a dimmer (not DALI) by pressing the "ON/OFF Button" instead of selecting by the slider, the light always starts at 100%. Is this correct or did i configure something wrong?

I couldn't have a deeper look into your code, to figure out how you programmed it, due to lack of time. In my REST-Configuration I had it that way that I called the event: "CLICK" on the "+" Button. This was the same as actually pressing on the physical button and turned the light on the same level as it was turned off before. That means: If it was turned OFF @ 50%, it turns ON at 50% again when pressing the button in the dashboard.

Do you think there is a probability to implement that in your code as well? I might find some time at the weekend to have a look at your code and maybe give a first code trial.

kess78 commented 2 months ago

Unfortunately I don't have any Dali or Dimmers in my installation, so I can not personally test. This PR changes the method on how a light is turned on or off by simulating a button click (exactly what you do with your Feller equipment with your fingers) instead of directly setting a brightness value to 0 or 100%.

Please try that one here: https://github.com/machgo/fellerwiserhomeassistant/pull/8 and kindly tell us if it's working or not.

tech-geek-4 commented 2 months ago

Please try that one here: #8 and kindly tell us if it's working or not.

Thanks for your fast suggestion. Unfortunately it didn't worked completely. Turning on and off the light worked perfectly and by turning on with the button the light went to the last brightness. Unfortunately the slider stopped working. Moving up or down set the light once to 100% and stopped working then. This is the same behaviour as when pressing the physical button.

For Info if it helps: The physical dimmer workes like that (light Off): Click "UP" -> Light turns on at latest level; Click "UP" again -> Light turns to 100%; Click "DOWN" -> Light turns off. Remaining on UP or DOWN: Light Dims.

I tried to change the light.py a little but didn't found a solution. I had in mind to call a command in refrence to the _state. If TRUE: Do the original code which works for the dimmer and if FALSE simulate only the button click. But unfortunately my Python skills are to poor to get it working and time this evening doesn't allow deeper study... :disappointed_relieved:

I also didn't found any info to only set the brightness in the HA-Devloper Docs... Maybe one of you has a further idea.

kess78 commented 2 months ago

As stated before, I'm not a lucky dimmer/dali owner, so I can not directly test it. But just to know what could be called to achieve what's needed, please play a bit with the Feller Wiser API and tell exectly which commands you send to do what you need.

Thank you

kess78 commented 2 months ago

As documented here: https://developers.home-assistant.io/docs/core/entity/light/ it's necessary to tell HA to use ColorMode, in our case it should be ColorMode.BRIGHTNESS. At the beginning of the next week I'll receive a dimmer, so I can test it. For Dali dimmers it should be exactly the same.

I'll let you know as soon as I have the right solution

tech-geek-4 commented 2 months ago

As stated before, I'm not a lucky dimmer/dali owner, so I can not directly test it. But just to know what could be called to achieve what's needed, please play a bit with the Feller Wiser API and tell exectly which commands you send to do what you need.

Thank you

Good Morning, Hope you didn't felt my answer as rude - that would have been not a little the idea. Tried to explain a little the dimmer as you don't have one but of course happy that you get one next week... :blush:

My code for the light was a little different as i didi it the way with a light template:

light:
  - platform: template
    lights:

  # Küchenspots     

      spots_kueche:
        friendly_name: "Spots Küche"
        value_template: "{{(((states('sensor.node_value_spots_kueche') | float(0)) / 39.2156863) | round (0)) > 0}}"
        level_template: "{{((states('sensor.node_value_spots_kueche') | float(0)) / 39.2156863) | round (0) }}"
        turn_on:
          service: rest_command.restfulspotkuecheupclick
        turn_off:
          service: rest_command.restfulspotkuechedownclick
        set_level:
          service: rest_command.restfulspotkueche
          data_template:
            value: "{{((brightness*39.2156863)| round (0))}}"

UP/DOWN-Rest Commands are basically: {"button":"up","event":"click"} Set Level Command is: {"bri": "Level of the Slider when moved" }

In the template the ON/OFF are called when pressing the button and Set Level when the Slider is moved which seems a bit different to the py-code...

I'll have a detailed look in the dev document this evening and maybe i'll understand it then... :wink:

machgo commented 2 months ago

The example with the click-event didn't work on my setup 😉

I've tried to store the old brightness before turning the light off. 3f07e8d Can you try the new version?

kess78 commented 2 months ago

I finally could test it. The PR https://github.com/machgo/fellerwiserhomeassistant/pull/10 fixes perfectly the issue ;-) Thank you @tech-geek-4

tech-geek-4 commented 1 month ago

@kess78 Thank you for the initial code!

I'm happy that i could help and contribute to the great work of this repo!