home-assistant / frontend

:lollipop: Frontend for Home Assistant
https://demo.home-assistant.io
Other
4.03k stars 2.75k forks source link

Scenes editor color saved incorrectly #5972

Closed ghost closed 4 years ago

ghost commented 4 years ago

Checklist

The problem

When I set the color of a MQTT light (only supports rgb) in the scenes editor the light turns to the correct color but when I then save that scene without doing any further changes and activate it from the UI. The light just turns white (RGB values of 255).

Expected behavior

The light should turn to it's set color in the scenes editor.

Steps to reproduce

  1. Set the color in the scenes editor
  2. Active the scene via the UI

Environment

State of relevant entities

Attributes of the light after scene was activated:

effect_list: bpm, candy cane, animations, template, blendwave, beatwave, blur, confetti, confetti 2, confetti pal, dotbeat, easing, every n example, fill grad, inoise8 mover, inoise8 pal, noise 16 1, noise 16 2, noise 16 3, one sine pal, palette cross fade, rainbow, rainbow with glitter, rainbow march, rainbow beat, ripple pal, cyclon rainbow, dots, fire, glitter, juggle, lightning, noise, police all, police one, ripple, sinelon, solid, twinkle, Christmas, St Patty, Valentine, Turkey Day, Thanksgiving, USA, Independence, Halloween, Go Lions, Hail, Touchdown, Punkin, Lovey Day, Holly Jolly
brightness: 204
hs_color: 0, 0
rgb_color: 255, 255, 255
xy_color: 0.323, 0.329
effect: solid
friendly_name: TV Licht
supported_features: 61
icon: mdi:creation

Problem-relevant configuration

The MQTT Light has the following config:

- platform: mqtt
  schema: json
  name: TV Licht
  state_topic: "led_strip/TVLicht/state"
  command_topic: "led_strip/TVLicht/command"
  effect: true
  effect_list:
    - solid
    - [...]
  brightness: true
  rgb: true
  optimistic: false
  qos: 0

Snippet from the scenes.yaml file when saved from the scenes editor:

- id: '1582893336076'
  name: Sonnenuntergang
  entities:
    light.tv_licht:
      brightness: 200
      effect: solid
      effect_list:
      - solid
      friendly_name: TV Licht
      hs_color:
      - 0
      - 0
      icon: mdi:creation
      rgb_color:
      - 255
      - 255
      - 255
      state: 'on'
      supported_features: 61
      xy_color:
      - 0.323
      - 0.329

Additional information

I noticed that when I configure the scene in the scenes editor and click on some color in the UI the physical color of the light changes but the values don't (as shown in the following screenshot)

Screenshot Scenes Editor with issue

For other MQTT lights (without JSON schema) the scenes editor works just fine and all the color values in the scenes.yaml file are set correctly.

bramkragten commented 4 years ago

This is an issue from MQTT, it reports all colour values, but doesn't update or hides the one not in use. We save these and then restore them, but we don't know what attribute had the right colour.

MQTT should only report the attribute with the right colour.

ghost commented 4 years ago

I investigated the MQTT messages that get send when I change the color in the scene editor. The message that is send to the command topic looks like this:

{
    "state": "ON",
    "color": {
        "r": 255,
        "g": 36,
        "b": 91
    }
}

The message that is received on the state topic looks like this:

{
    "state": "ON",
    "color": {},
    "r": 255,
    "g": 36,
    "b": 91,
    "brightness": 165,
    "effect": "solid"
}

My problem is the formatting of the state topic in my special case. I will have to investigate further why the RGB values are not nested under the color attribute. For testing purposes I sent the message from the command topic to the state topic and that's how I was able to solve the issue I had. And when I save the scene also the correct color values are stored in the file. So sorry that mistake was in my configuration and not in the scenes editor.

@bramkragten Thanks for your reply! You got me in the direction of thinking to investigate my MQTT messages further and that's where my problem was.