Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Home Assistant discovery: add color_mode for lights #7057

Merged
merged 4 commits into from
Apr 25, 2021
Merged

Conversation

Koenkk
Copy link
Owner

@Koenkk Koenkk commented Apr 12, 2021

Adds support for color_mode which has been added in 2021.4.0.

@Koenkk
Copy link
Owner Author

Koenkk commented Apr 12, 2021

@emontnemery implementing the color_mode now but for some reason HA doesn't show any pickers after adding color_mode/supported_color_modes. Any idea what is wrong? (HA 2021.4.3)

image

@emontnemery
Copy link

emontnemery commented Apr 13, 2021

@Koenkk the frontend issue should be fixed by home-assistant/core#49167

@Koenkk
Copy link
Owner Author

Koenkk commented Apr 13, 2021

@emontnemery thanks, I will continue this implementation when the fix is in a HA release.

@emontnemery
Copy link

emontnemery commented Apr 16, 2021

Fixed in Home Assistant 2021.4.5

@Koenkk Koenkk merged commit 7631c19 into dev Apr 25, 2021
@Koenkk Koenkk deleted the feature/ha_colormode branch April 25, 2021 12:56
@Koenkk
Copy link
Owner Author

Koenkk commented Apr 25, 2021

@emontnemery looks good now indeed. Will be available in next z2m release on 1 May

@bramkragten
Copy link

bramkragten commented May 2, 2021

@Koenkk this is not backward compatible for older versions of Home Assistant, is that intended?

NVM, I see you mention it in the release notes 😄

@kevincaradant
Copy link

kevincaradant commented May 28, 2021

Hi @Koenkk

Sorry I don"tknow if I shoud write here or create an other issue after mine (#7125 (comment)) but it's still about color_mode: xy.

My issue is not resolved. And seems to be the same issue than in my previous issue mentioned before.

Here is the normal state for my bulbs

---- COLOR OK AND BRIGHTNESS OK
Info MQTT publish: topic 'zigbee2mqtt/Z2M_livingroom_lights', payload '{"brightness":90,"color":{"x":0.4632,"y":0.4113},"color_mode":"color_temp","color_temp":375,"state":"ON"}'
Info MQTT publish: topic 'zigbee2mqtt/gledopto_2_livingroom', payload '{"brightness":90,"color":{"x":0.4632,"y":0.4113},"color_mode":"color_temp","color_temp":375,"linkquality":null,"state":"ON"}'

Here is when I have a specific animation (blink) (alarm in red with rgb [255,0,0]) and brightness with the value at 140. The value sent is 139 but it's not a big deal.

MQTT publish: topic 'zigbee2mqtt/Z2M_livingroom_lights', payload '{"brightness":139,"color":{"x":0.701,"y":0.299},"color_mode":"xy","color_temp":159,"state":"ON"}'
Info MQTT publish: topic 'zigbee2mqtt/gledopto_2_livingroom', payload '{"brightness":139,"color":{"x":0.701,"y":0.299},"color_mode":"xy","color_temp":159,"linkquality":null,"state":"ON"}'

Here is when I asked to "restore" the snapshot

--- COLOR WEIRD AND BRIGHTNESS OK
--- X AT 0.464 INSTEAD OF 0.4632 AND Y AT 0.411 INSTEAD OF 0.41113
Info MQTT publish: topic 'zigbee2mqtt/gledopto_4_livingroom', payload '{"brightness":90,"color":{"x":0.464,"y":0.411},"color_mode":"xy","color_temp":378,"linkquality":null,"state":"ON"}'
Info MQTT publish: topic 'zigbee2mqtt/gledopto_5_livingroom', payload '{"brightness":90,"color":{"x":0.464,"y":0.411},"color_mode":"xy","color_temp":378,"linkquality":null,"state":"ON"}'

Why the color_mode is not restored ? why "xy" instead of "color_temp", I don't know if it's related to this issue or not but in my case, the snapshot is still not working :(

Thank you

Regards

Version Zigbee2MQTT
1.18.3-dev commit: 7185741
Type de Coordinateur
zStack3x0
Révision du Coordinateur
20201130
Version Interface
0.4.15

Home Assistant 2021.5.5

@Koenkk
Copy link
Owner Author

Koenkk commented May 28, 2021

@kevincaradant please also provide the debug log of this. This will show the received MQTT messages.
See https://www.zigbee2mqtt.io/information/debug.html on how to enable debug logging.

@kevincaradant
Copy link

kevincaradant commented May 29, 2021

Is it what you asked ? Sorry, I'm not sure what you need in debug mode, I copy paste all the logs
Normal State

Zigbee2MQTT:debug 2021-05-29 11:26:39: Received MQTT message on 'zigbee2mqtt/Z2M_livingroom_lights/set' with data '{"state": "ON"}'
Zigbee2MQTT:debug 2021-05-29 11:26:39: Publishing 'set' 'state' to 'Z2M_livingroom_lights'
Zigbee2MQTT:info  2021-05-29 11:26:39: MQTT publish: topic 'zigbee2mqtt/gledopto_1_livingroom', payload '{"brightness":90,"color":{"x":0.4632,"y":0.4113},"color_mode":"color_temp","color_temp":375,"linkquality":null,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:26:39: MQTT publish: topic 'zigbee2mqtt/Z2M_livingroom_lights', payload '{"brightness":90,"color":{"x":0.4632,"y":0.4113},"color_mode":"color_temp","color_temp":375,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:26:39: MQTT publish: topic 'zigbee2mqtt/gledopto_2_livingroom', payload '{"brightness":90,"color":{"x":0.4632,"y":0.4113},"color_mode":"color_temp","color_temp":375,"linkquality":null,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:26:39: MQTT publish: topic 'zigbee2mqtt/gledopto_3_livingroom', payload '{"brightness":90,"color":{"x":0.4632,"y":0.4113},"color_mode":"color_temp","color_temp":375,"linkquality":null,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:26:39: MQTT publish: topic 'zigbee2mqtt/gledopto_4_livingroom', payload '{"brightness":90,"color":{"x":0.4632,"y":0.4113},"color_mode":"color_temp","color_temp":375,"linkquality":null,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:26:39: MQTT publish: topic 'zigbee2mqtt/gledopto_5_livingroom', payload '{"brightness":90,"color":{"x":0.4632,"y":0.4113},"color_mode":"color_temp","color_temp":375,"linkquality":null,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:26:39: MQTT publish: topic 'zigbee2mqtt/gledopto_1_couloir_livingroom', payload '{"brightness":90,"color":{"x":0.4632,"y":0.4113},"color_mode":"color_temp","color_temp":375,"linkquality":null,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:26:39: MQTT publish: topic 'zigbee2mqtt/gledopto_2_couloir_livingroom', payload '{"brightness":90,"color":{"x":0.4632,"y":0.4113},"color_mode":"color_temp","color_temp":375,"linkquality":null,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:26:39: MQTT publish: topic 'zigbee2mqtt/Z2M_all_lights', payload '{"brightness":90,"color":{"x":0.4632,"y":0.4113},"color_mode":"color_temp","color_temp":375,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:26:39: MQTT publish: topic 'zigbee2mqtt/Z2M_alarm_lights', payload '{"brightness":90,"color":{"x":0.4632,"y":0.4113},"color_mode":"color_temp","color_temp":375,"state":"ON"}'

Alarm State ( red blink)

igbee2MQTT:info  2021-05-29 11:16:23: MQTT publish: topic 'zigbee2mqtt/gledopto_1_couloir_livingroom', payload '{"brightness":139,"color":{"x":0.701,"y":0.299},"color_mode":"xy","color_temp":159,"linkquality":null,"state":"OFF"}'
Zigbee2MQTT:info  2021-05-29 11:16:23: MQTT publish: topic 'zigbee2mqtt/gledopto_2_couloir_livingroom', payload '{"brightness":139,"color":{"x":0.701,"y":0.299},"color_mode":"xy","color_temp":159,"linkquality":null,"state":"OFF"}'
Zigbee2MQTT:debug 2021-05-29 11:16:24: Received MQTT message on 'zigbee2mqtt/Z2M_livingroom_lights/set' with data '{"state": "ON"}'
Zigbee2MQTT:debug 2021-05-29 11:16:24: Publishing 'set' 'state' to 'Z2M_livingroom_lights'
Zigbee2MQTT:info  2021-05-29 11:16:24: MQTT publish: topic 'zigbee2mqtt/gledopto_1_livingroom', payload '{"brightness":139,"color":{"x":0.701,"y":0.299},"color_mode":"xy","color_temp":159,"linkquality":null,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:16:24: MQTT publish: topic 'zigbee2mqtt/Z2M_livingroom_lights', payload '{"brightness":139,"color":{"x":0.701,"y":0.299},"color_mode":"xy","color_temp":159,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:16:24: MQTT publish: topic 'zigbee2mqtt/gledopto_2_livingroom', payload '{"brightness":139,"color":{"x":0.701,"y":0.299},"color_mode":"xy","color_temp":159,"linkquality":null,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:16:24: MQTT publish: topic 'zigbee2mqtt/gledopto_3_livingroom', payload '{"brightness":139,"color":{"x":0.701,"y":0.299},"color_mode":"xy","color_temp":159,"linkquality":null,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:16:24: MQTT publish: topic 'zigbee2mqtt/gledopto_4_livingroom', payload '{"brightness":139,"color":{"x":0.701,"y":0.299},"color_mode":"xy","color_temp":159,"linkquality":null,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:16:24: MQTT publish: topic 'zigbee2mqtt/gledopto_5_livingroom', payload '{"brightness":139,"color":{"x":0.701,"y":0.299},"color_mode":"xy","color_temp":159,"linkquality":null,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:16:24: MQTT publish: topic 'zigbee2mqtt/gledopto_1_couloir_livingroom', payload '{"brightness":139,"color":{"x":0.701,"y":0.299},"color_mode":"xy","color_temp":159,"linkquality":null,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:16:24: MQTT publish: topic 'zigbee2mqtt/gledopto_2_couloir_livingroom', payload '{"brightness":139,"color":{"x":0.701,"y":0.299},"color_mode":"xy","color_temp":159,"linkquality":null,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:16:24: MQTT publish: topic 'zigbee2mqtt/Z2M_all_lights', payload '{"brightness":139,"color":{"x":0.701,"y":0.299},"color_mode":"xy","color_temp":159,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:16:24: MQTT publish: topic 'zigbee2mqtt/Z2M_alarm_lights', payload '{"brightness":139,"color":{"x":0.701,"y":0.299},"color_mode":"xy","color_temp":159,"state":"ON"}'

When I desarm the alarm, it shoukd restore my snapshot ( like the 'normal state' logs mentioned before)

Zigbee2MQTT:debug 2021-05-29 11:16:24: Received MQTT message on 'zigbee2mqtt/Z2M_livingroom_lights/set' with data '{"state": "ON", "color": {"x": 0.464, "y": 0.411}, "brightness": 90}'
Zigbee2MQTT:debug 2021-05-29 11:16:24: Publishing 'set' 'brightness' to 'Z2M_livingroom_lights'
Zigbee2MQTT:info  2021-05-29 11:16:25: MQTT publish: topic 'zigbee2mqtt/gledopto_1_livingroom', payload '{"brightness":90,"color":{"x":0.701,"y":0.299},"color_mode":"xy","color_temp":159,"linkquality":null,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:16:25: MQTT publish: topic 'zigbee2mqtt/Z2M_livingroom_lights', payload '{"brightness":90,"color":{"x":0.701,"y":0.299},"color_mode":"xy","color_temp":159,"state":"ON"}'
Zigbee2MQTT:debug 2021-05-29 11:16:25: Publishing 'set' 'color' to 'Z2M_livingroom_lights'
Zigbee2MQTT:info  2021-05-29 11:16:25: MQTT publish: topic 'zigbee2mqtt/gledopto_2_livingroom', payload '{"brightness":90,"color":{"x":0.701,"y":0.299},"color_mode":"xy","color_temp":159,"linkquality":null,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:16:25: MQTT publish: topic 'zigbee2mqtt/gledopto_3_livingroom', payload '{"brightness":90,"color":{"x":0.701,"y":0.299},"color_mode":"xy","color_temp":159,"linkquality":null,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:16:25: MQTT publish: topic 'zigbee2mqtt/gledopto_4_livingroom', payload '{"brightness":90,"color":{"x":0.701,"y":0.299},"color_mode":"xy","color_temp":159,"linkquality":null,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:16:25: MQTT publish: topic 'zigbee2mqtt/gledopto_5_livingroom', payload '{"brightness":90,"color":{"x":0.701,"y":0.299},"color_mode":"xy","color_temp":159,"linkquality":null,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:16:25: MQTT publish: topic 'zigbee2mqtt/gledopto_1_couloir_livingroom', payload '{"brightness":90,"color":{"x":0.701,"y":0.299},"color_mode":"xy","color_temp":159,"linkquality":null,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:16:25: MQTT publish: topic 'zigbee2mqtt/gledopto_2_couloir_livingroom', payload '{"brightness":90,"color":{"x":0.701,"y":0.299},"color_mode":"xy","color_temp":159,"linkquality":null,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:16:25: MQTT publish: topic 'zigbee2mqtt/Z2M_all_lights', payload '{"brightness":90,"color":{"x":0.701,"y":0.299},"color_mode":"xy","color_temp":159,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:16:25: MQTT publish: topic 'zigbee2mqtt/Z2M_alarm_lights', payload '{"brightness":90,"color":{"x":0.701,"y":0.299},"color_mode":"xy","color_temp":159,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:16:25: MQTT publish: topic 'zigbee2mqtt/gledopto_1_livingroom', payload '{"brightness":90,"color":{"x":0.464,"y":0.411},"color_mode":"xy","color_temp":378,"linkquality":null,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:16:25: MQTT publish: topic 'zigbee2mqtt/Z2M_livingroom_lights', payload '{"brightness":90,"color":{"x":0.464,"y":0.411},"color_mode":"xy","color_temp":378,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:16:25: MQTT publish: topic 'zigbee2mqtt/gledopto_2_livingroom', payload '{"brightness":90,"color":{"x":0.464,"y":0.411},"color_mode":"xy","color_temp":378,"linkquality":null,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:16:25: MQTT publish: topic 'zigbee2mqtt/gledopto_3_livingroom', payload '{"brightness":90,"color":{"x":0.464,"y":0.411},"color_mode":"xy","color_temp":378,"linkquality":null,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:16:25: MQTT publish: topic 'zigbee2mqtt/gledopto_4_livingroom', payload '{"brightness":90,"color":{"x":0.464,"y":0.411},"color_mode":"xy","color_temp":378,"linkquality":null,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:16:25: MQTT publish: topic 'zigbee2mqtt/gledopto_5_livingroom', payload '{"brightness":90,"color":{"x":0.464,"y":0.411},"color_mode":"xy","color_temp":378,"linkquality":null,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:16:25: MQTT publish: topic 'zigbee2mqtt/gledopto_1_couloir_livingroom', payload '{"brightness":90,"color":{"x":0.464,"y":0.411},"color_mode":"xy","color_temp":378,"linkquality":null,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:16:25: MQTT publish: topic 'zigbee2mqtt/gledopto_2_couloir_livingroom', payload '{"brightness":90,"color":{"x":0.464,"y":0.411},"color_mode":"xy","color_temp":378,"linkquality":null,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:16:25: MQTT publish: topic 'zigbee2mqtt/Z2M_all_lights', payload '{"brightness":90,"color":{"x":0.464,"y":0.411},"color_mode":"xy","color_temp":378,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:16:25: MQTT publish: topic 'zigbee2mqtt/Z2M_alarm_lights', payload '{"brightness":90,"color":{"x":0.464,"y":0.411},"color_mode":"xy","color_temp":378,"state":"ON"}'
Zigbee2MQTT:debug 2021-05-29 11:16:25: Received MQTT message on 'zigbee2mqtt/Z2M_livingroom_lights/set' with data '{"state": "ON"}'
Zigbee2MQTT:debug 2021-05-29 11:16:25: Publishing 'set' 'state' to 'Z2M_livingroom_lights'
Zigbee2MQTT:info  2021-05-29 11:16:25: MQTT publish: topic 'zigbee2mqtt/gledopto_1_livingroom', payload '{"brightness":90,"color":{"x":0.464,"y":0.411},"color_mode":"xy","color_temp":378,"linkquality":null,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:16:25: MQTT publish: topic 'zigbee2mqtt/Z2M_livingroom_lights', payload '{"brightness":90,"color":{"x":0.464,"y":0.411},"color_mode":"xy","color_temp":378,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:16:25: MQTT publish: topic 'zigbee2mqtt/gledopto_2_livingroom', payload '{"brightness":90,"color":{"x":0.464,"y":0.411},"color_mode":"xy","color_temp":378,"linkquality":null,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:16:25: MQTT publish: topic 'zigbee2mqtt/gledopto_3_livingroom', payload '{"brightness":90,"color":{"x":0.464,"y":0.411},"color_mode":"xy","color_temp":378,"linkquality":null,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:16:25: MQTT publish: topic 'zigbee2mqtt/gledopto_4_livingroom', payload '{"brightness":90,"color":{"x":0.464,"y":0.411},"color_mode":"xy","color_temp":378,"linkquality":null,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:16:25: MQTT publish: topic 'zigbee2mqtt/gledopto_5_livingroom', payload '{"brightness":90,"color":{"x":0.464,"y":0.411},"color_mode":"xy","color_temp":378,"linkquality":null,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:16:25: MQTT publish: topic 'zigbee2mqtt/gledopto_1_couloir_livingroom', payload '{"brightness":90,"color":{"x":0.464,"y":0.411},"color_mode":"xy","color_temp":378,"linkquality":null,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:16:25: MQTT publish: topic 'zigbee2mqtt/gledopto_2_couloir_livingroom', payload '{"brightness":90,"color":{"x":0.464,"y":0.411},"color_mode":"xy","color_temp":378,"linkquality":null,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:16:25: MQTT publish: topic 'zigbee2mqtt/Z2M_all_lights', payload '{"brightness":90,"color":{"x":0.464,"y":0.411},"color_mode":"xy","color_temp":378,"state":"ON"}'
Zigbee2MQTT:info  2021-05-29 11:16:25: MQTT publish: topic 'zigbee2mqtt/Z2M_alarm_lights', payload '{"brightness":90,"color":{"x":0.464,"y":0.411},"color_mode":"xy","color_temp":378,"state":"ON"}'
Zigbee2MQTT:debug 2021-05-29 11:16:26: Received MQTT message on 'zigbee2mqtt/centralite/set' with data '{"arm_mode":{"transaction":99,"mode":"disarm"}}'
Zigbee2MQTT:debug 2021-05-29 11:16:26: Publishing 'set' 'arm_mode' to 'centralite'
Zigbee2MQTT:debug 2021-05-29 11:16:28: Received Zigbee message from 'router_pc_desktop', type 'attributeReport', cluster 'seMetering', data '{"currentSummDelivered":[0,2698000],"currentSummReceived":[0,0],"instantaneousDemand":92}' from endpoint 1 with groupID 0
Zigbee2MQTT:info  2021-05-29 11:16:28: MQTT publish: topic 'zigbee2mqtt/router_pc_desktop', payload '{"energy":269.8,"linkquality":114,"power":9.2,"state":"ON"}'
Zigbee2MQTT:debug 2021-05-29 11:16:34: Received Zigbee message from 'router_bathroom', type 'attributeReport', cluster 'seMetering', data '{"currentSummDelivered":[0,7000],"currentSummReceived":[0,0],"instantaneousDemand":2}' from endpoint 1 with groupID 0

@Koenkk
Copy link
Owner Author

Koenkk commented May 29, 2021

Why the color_mode is not restored ? why "xy" instead of "color_temp", I don't know if it's related to this issue or not but in my case, the snapshot is still not working :(

As can be seen in your last log you see that z2m receives the following: Zigbee2MQTT:debug 2021-05-29 11:16:24: Received MQTT message on 'zigbee2mqtt/Z2M_livingroom_lights/set' with data '{"state": "ON", "color": {"x": 0.464, "y": 0.411}, "brightness": 90}' This payload request a specific color x/y to be set, therefore the color mode is set to XY. So from the z2m perspective this looks as expected.

@emontnemery
Copy link

Can you explain what you're doing in Home Assistant, are you restoring a scene?

@kevincaradant
Copy link

kevincaradant commented May 29, 2021

@emontnemery It was explained a little bit on the old thread but you will find it more detailed just below.
Maybe I made a mistake, I let you to tell me ;)

Sorry @Koenkk if I write a little bit of HA code here :)

The idea is that someone opens the door, the alarm is triggered ( light go on red blinking ) and then when I disable the alarm, I want to have again the previous state of my bulbs.

This is the state before to trigger the alarm (color_temp at 375)
image

- alias: "Alarm From RAS To Triggered"
  trigger:
    - platform: state
      entity_id: alarm_control_panel.alarm
      to: "triggered"
  action:
    - service: light.turn_on
      data:
        entity_id: light.livingroom_lights
    - service: scene.create
      data:
        scene_id: before
        snapshot_entities:
          - light.livingroom_lights
    - service: light.turn_on
      data:
        entity_id: light.livingroom_lights
        brightness: 140
        rgb_color: [255,0,0]
    - repeat:
        until:
          - condition: state
            entity_id: alarm_control_panel.alarm
            state: "disarmed"
        sequence:
          - service: light.toggle
            data:
              entity_id: light.livingroom_lights
          - delay:
              milliseconds: 1300
    - service: homeassistant.turn_on
      entity_id: switch.siren
    - service: notify.notify_events
      data:
        message: "CALL THE POLICE !"
        data:
          level: 'warning'
          priority: 'high'
    - service: timer.start
      entity_id: timer.alarm_pending

And when I stop the alarm

- alias: "Alarm From Triggered To Disarmed"
  trigger:
    - platform: state
      entity_id: alarm_control_panel.alarm
      from: "triggered"
      to: "disarmed"
  action:
    - service: scene.turn_on
      data:
        entity_id: scene.before
    - delay:
        milliseconds: 500
    - service: light.turn_on
      data:
        entity_id: light.livingroom_lights
    - service: homeassistant.turn_off
      entity_id: switch.siren

Do you need others information ?

@emontnemery
Copy link

@kevincaradant that should work, so either zigbee2mqtt is not setting the color mode correctly or there is a bug in Home Assistant.

Can you collect+attach a log from Home Assistant with the following settings covering the following sequence of events:

  1. You set the bulb to color_temp 375
  2. The alarm is triggered, light is set to red
  3. Alarm is stopped, Home Assistant attempts (and fails) to restore the light to color_temp 375
logger:
  default: info
  logs:
    homeassistant.components.automation: debug
    homeassistant.core: debug
    homeassistant.components.mqtt: debug

@kevincaradant
Copy link

kevincaradant commented May 30, 2021

@emontnemery , I tried as I could, because I have sooooooo much logs in debug mode in HA, that after 2 seconds, I was lost x)
Sorry for the huge logs ...
To find more easily something, search brightness at 90 ( normal state ) or at 139 ( alarm state )

Finally I can't send all the logs, I added in attachment a file with all the logs.
https://file.io/J3IR8h1CI479

@emontnemery
Copy link

emontnemery commented May 30, 2021

@kevincaradant don't worry about the size of the logs, you can simply zip the log file and attach it to a github comment by dragging+dropping it onto the comment, there's no need to rely on 3rd party services 👍

Edit: The file.io link doesn't work, please attach the log file directly in github instead

@emontnemery
Copy link

The file.io link works now.

You set the light to color_temp=380:

2021-05-30 11:39:14 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=light, service=turn_on, service_data=entity_id=light.livingroom_lights, color_temp=380>
2021-05-30 11:39:14 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=mqtt, service=publish, service_data=topic=zigbee2mqtt/Z2M_livingroom_lights/set, qos=0, retain=False, payload={"state": "ON", "color_temp": 380}>

The state update from the light reports that it's in color_mode=color_temp

2021-05-30 11:39:14 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on zigbee2mqtt/Z2M_livingroom_lights: b'{"brightness":90,"color":{"x":0.4657,"y":0.4118},"color_mode":"color_temp","color_temp":380,"state":"ON"}'

However, Home Assistant sets it to color_mode=hs

2021-05-30 11:39:14 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=light.livingroom_lights, old_state=<state light.livingroom_lights=on; min_mireds=153, max_mireds=500, effect_list=None, supported_color_modes=['color_temp', 'hs'], color_mode=hs, brightness=90, hs_color=(37.986, 54.51), rgb_color=(255, 204, 115), xy_color=(0.464, 0.411), color_temp=375, friendly_name=Livingroom Lights, icon=mdi:lightbulb-group, supported_features=63 @ 2021-05-30T11:34:17.675230+02:00>, new_state=<state light.livingroom_lights=on; min_mireds=153, max_mireds=500, effect_list=None, supported_color_modes=['color_temp', 'hs'], color_mode=hs, brightness=90, hs_color=(37.872, 55.294), rgb_color=(255, 202, 114), xy_color=(0.466, 0.409), color_temp=380, friendly_name=Livingroom Lights, icon=mdi:lightbulb-group, supported_features=63 @ 2021-05-30T11:34:17.675230+02:00>>

This will happen if the color_mode flag is not enabled in the light's discovery message.
Can you check the discovery message of the light, you can find it under configuration->devices->[the device]->MQTT info

@kevincaradant
Copy link

kevincaradant commented May 30, 2021

Just to mention it. I didn't find the Z2M group from the 'devices' section. I only find the bulbs individually. So I took one of them

This is what I have

Screenshot_20210530-141034_Home Assistant

And an example of messages. I don't know exactly the field that you expected
Screenshot_20210530-181346_Home Assistant

@emontnemery
Copy link

Please get the discovery message for the group, you can get it from command line:
mosquitto_sub -v -h <mqtt server> -t homeassistant/light/#

@kevincaradant
Copy link

kevincaradant commented May 31, 2021

I didn't sucess to use this command. I'm using a docker container for mosquitto and also my lights group "livingroom_lights" is a group as Z2M entity.
image

It's not a group under homeassistant. For HA, it's just a light from the "Light.yaml"
This is my MQTT config to use the light group (Z2M) into Light entity (HA)

- platform: mqtt
  schema: json
  name: Livingroom Lights
  unique_id: livingroom_lights
  command_topic: zigbee2mqtt/Z2M_livingroom_lights/set
  state_topic: zigbee2mqtt/Z2M_livingroom_lights
  color_temp: true
  brightness: true
  effect: true
  xy: true
  brightness_scale: 254

Here, you can see the color_temp at true

From MQTT Explorer application,

I can see the xy value is lost when I set the rgb to red color. Is it normal at this state to have "xy" ? And it should be only when I restore it that the "color_temp" should be back ? Or even in RGB I should ahve "color_temp" setted ?

For me it's normal to have xy ( during alarm ) but I'm not fully sure ...

image

THis is what I have at the end as latest MQTT message
image

Is it what you want as answer @emontnemery ?

@emontnemery
Copy link

OK, so you have manually configured the light group like this, it's not automatically exposed by zigbee2mqtt:

- platform: mqtt
  schema: json
  name: Livingroom Lights
  unique_id: livingroom_lights
  command_topic: zigbee2mqtt/Z2M_livingroom_lights/set
  state_topic: zigbee2mqtt/Z2M_livingroom_lights
  color_temp: true
  brightness: true
  effect: true
  xy: true
  brightness_scale: 254

That configuration is in Home Assistant's configuration.yaml, correct?

The configuration is wrong, and that's why it doesn't work.
Why don't you rely on automatic discovery of the group, is it not supported by zigbee2mqtt?

@emontnemery
Copy link

OK, I found in the documentation that it requires manual configuration: https://www.zigbee2mqtt.io/integration/home_assistant.html#groups

The documentation needs to be updated to explain that color_mode and supported_color_modes must be enabled for groups. @Koenkk can you help to update the configuration?

@emontnemery
Copy link

@kevincaradant in your case, please try to update the group config like this:

- platform: mqtt
  schema: json
  name: Livingroom Lights
  unique_id: livingroom_lights
  command_topic: zigbee2mqtt/Z2M_livingroom_lights/set
  state_topic: zigbee2mqtt/Z2M_livingroom_lights
  effect: true
  brightness_scale: 254
  color_mode: true
  supported_color_modes: ["color_temp", "xy"]

@kevincaradant
Copy link

kevincaradant commented May 31, 2021

@emontnemery well done :)

I didn't see this option in the documentation of HA but it's well explained indeed.
https://www.home-assistant.io/integrations/light.mqtt/

Thank you a lot :D

@Koenkk, not sure about it, I have a little remember about an issue on auto discovery with groups. Is it always on your roadmap ? I just find this #2410 but I was sure there is something else somewhere :)

Koenkk added a commit to Koenkk/zigbee2mqtt.io that referenced this pull request May 31, 2021
@Koenkk
Copy link
Owner Author

Koenkk commented May 31, 2021

@emontnemery updates the docs! Thanks for helping out!

@kevincaradant yes, still on my roadmap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants