StyraHem / ShellyForHASS

Shelly smart home platform for Home Assistant
MIT License
615 stars 110 forks source link

[BUG] light unavailable after 2022.9.0 upadate #713

Open damianbraun opened 1 year ago

damianbraun commented 1 year ago

Environment

Describe the bug

After 2022.9.0 update, light entities of shelly dimmer 2's became unavailable.

Steps to Reproduce

Expected behavior

Screenshots

Traceback/Error logs

Logger: homeassistant.setup Source: setup.py:320 First occurred: 20:14:23 (3 occurrences) Last logged: 20:21:03

Unable to prepare setup for platform shelly.light: Platform not found (cannot import name 'ATTR_WHITE_VALUE' from 'homeassistant.components.light' (/usr/src/homeassistant/homeassistant/components/light/init.py)).

Additional context

hakana commented 1 year ago

How is it working in core integration. Is there two entities, one for rgb and one for white channel? Can you take a screen shot?


From: doug62 @.> Sent: Saturday, September 17, 2022 5:07:05 AM To: StyraHem/ShellyForHASS @.> Cc: Håkan Åkerberg @.>; Mention @.> Subject: Re: [StyraHem/ShellyForHASS] [BUG] light unavailable after 2022.9.0 upadate (Issue #713)

@hakanahttps://github.com/hakana - Thanks for your work, earlier you were asking for a pattern, i have confirmed that the core shelly rgbw2 works same as this used to flawlessly, I'm not a python dev, looking at their code at https://github.dev/home-assistant/core/blob/38b087d2209dbe26f90676ecebf90fc1b97836e3/homeassistant/components/shelly/light.py#L12

— Reply to this email directly, view it on GitHubhttps://github.com/StyraHem/ShellyForHASS/issues/713#issuecomment-1249986008, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAI5KDSOIFQW7ZDCEJJZQ63V6UYVTANCNFSM6AAAAAAQHBGP5Q. You are receiving this because you were mentioned.Message ID: @.***>

doug62 commented 1 year ago

WIZ: (Color) image

WIZ Temperature: image

LIFX: image

david-kalbermatten commented 1 year ago

How is it working in core integration. Is there two entities, one for rgb and one for white channel? Can you take a screen shot?

The core integration offers white brightness and color brightness but the overall brightness slider only affects the RGB component. image

Dilergore commented 1 year ago

I have a more or less working setup with MQTT default light schema, if you want to use it just change the <deviceId> to the proper value:

mqtt:
  light:
    - name: "ledstrip"
      qos: 2
      rgbw_command_topic: "shellies/shellyrgbw2-<deviceId>/color/0/set"
      rgbw_state_topic: "shellies/shellyrgbw2-<deviceId>/color/0/status"
      rgbw_command_template: >
        {"red": {{ red }}, "green": {{ green }}, "blue": {{ blue }}, "white": {{ white }} }
      rgbw_value_template: > 
        {{value_json.red|int}},{{value_json.green|int}},{{value_json.blue|int}},{{value_json.white|int}}
      brightness_scale: 100
      brightness_command_topic: "shellies/shellyrgbw2-<deviceId>/color/0/set"
      brightness_state_topic: "shellies/shellyrgbw2-<deviceId>/color/0/status"
      brightness_command_template: >
        {%- if value == 1 -%}
          { "gain": 0 }
        {%- else -%}
          { "gain": {{ value }} }
        {%- endif -%}
      brightness_value_template: "{{ value_json.gain }}"
      command_topic: "shellies/shellyrgbw2-<deviceId>/color/0/command"
      state_topic: "shellies/shellyrgbw2-<deviceId>/color/0/status"
      payload_on: "on"
      payload_off: "off"
      state_value_template: >
        {%- if value_json.ison -%}
          on
        {%- else -%}
          off
        {%- endif -%}
      effect_list:
        - 0
        - 1
        - 2
        - 3
        - 4
        - 5
        - 6
      effect_command_topic: "shellies/shellyrgbw2-<deviceId>/color/0/set"
      effect_state_topic: "shellies/shellyrgbw2-<deviceId>/color/0/status"
      effect_command_template: >
        {"effect": {{ value }} }
      effect_value_template: "{{ value_json.effect }}"

The way this works is the following:

The problem with this in general is that while the normal more-info dialog has an option for "White Brightness", you cannot add it on the UI in any way as a slider (or I haven't yet found an option).

Update 9/29/2022:

I realized I had a bug in the above code, so I updated the post with the working one. After fixing some of the issues, I can confirm that I can control the white value with a slider using slider-entity-row. Using the above I have a working setup which does the exact same as before.

Also please note that the brightness_command_template is defined in a way that if `brightness' equals to 1 that is actually 0. It is this way to be able to change gain to 0 without turning the light off (In case you only want white and no RGB).