danielwelch / hassio-zigbee2mqtt

Hass.io add-on for zigbee2mqtt
Apache License 2.0
565 stars 190 forks source link

Light is automatically turning on (sometimes) if automation has turned it off #525

Closed ceesvanegmond closed 3 years ago

ceesvanegmond commented 3 years ago

Hi all, I've a weird problem using zigbee2mqtt in Home Assistant where my light is turning itself on after it's turned off by a automation

---
platform: mqtt
schema: json
name: kitchen
command_topic: "zigbee2mqtt/Kitchen/set"
state_topic: "zigbee2mqtt/Kitchen"
color_temp: true
brightness: true

So I have this simple automation for turning kitchen light on which is working flawlessly.

---
alias: Lampen - Turn on kitchen lights by movement
description: ''

trigger:
  - entity_id: binary_sensor.kitchen_motion_occupancy
    platform: state
    from: 'off'
    to: 'on'

condition:
  condition: or
  conditions:
    - condition: numeric_state
      entity_id: sensor.kitchen_motion_illuminance_lux
      below: 101

action:
  - service: light.turn_on
    data:
      entity_id: light.kitchen

And this automation to turn light off when no motion detected:

---
alias: Lampen - Turn off kitchen light
description: ''

trigger:
  - entity_id: binary_sensor.kitchen_motion_occupancy
    platform: state
    to: 'off'
    for:
      minutes: 1

condition: []

action:
  - service: light.turn_off
    data:
      entity_id: light.kitchen

Weirdly; sometimes when the light turns off automatically by the automation; the light is turning on again. And I don't know why. When checking out the logbook in HA something is weird. As the screenshot says: 'Keuken (which is kitchen in English' turned on by service.light.turn_on'. So that seems to me that there's no other automation that is triggering this randomly turned off light.

Schermafbeelding 2021-02-01 om 22 04 56

These are the zigbee2mqtt logs. The first line is automation that's beiing triggered to turn the light off. A few seconds after that; for some reason the light is turning on itself.

INFO: MQTT publish: topic 'zigbee2mqtt/Kitchen', payload '{"brightness":145,"color":{"x":0.476993298233858,"y":0.413675289942435},"color_temp":400,"state":"OFF"}'
INFO: MQTT publish: topic 'zigbee2mqtt/Kitchen 2', payload '{"brightness":145,"color":{"x":0.476993298233858,"y":0.413675289942435},"color_temp":400,"linkquality":57,"state":"OFF","update":{"state":"idle"},"update_available":false}'
INFO: MQTT publish: topic 'zigbee2mqtt/Kitchen 3', payload '{"brightness":145,"color":{"x":0.476993298233858,"y":0.413675289942435},"color_temp":400,"linkquality":78,"state":"OFF","update":{"state":"idle"},"update_available":false}'
INFO: MQTT publish: topic 'zigbee2mqtt/Livingroom 1', payload '{"brightness":36,"color_temp":500,"linkquality":54,"state":"ON","update":{"state":"idle"},"update_available":false}'
INFO: MQTT publish: topic 'zigbee2mqtt/Kitchen 1', payload '{"brightness":145,"color":{"x":0.476993298233858,"y":0.413675289942435},"color_temp":400,"linkquality":87,"state":"ON","update":{"state":"idle"},"update_available":false}'
INFO: MQTT publish: topic 'zigbee2mqtt/Kitchen', payload '{"brightness":145,"color":{"x":0.476993298233858,"y":0.413675289942435},"color_temp":400,"state":"ON"}'
INFO: MQTT publish: topic 'zigbee2mqtt/Kitchen 2', payload '{"brightness":145,"color":{"x":0.476993298233858,"y":0.413675289942435},"color_temp":400,"linkquality":57,"state":"ON","update":{"state":"idle"},"update_available":false}'
INFO: MQTT publish: topic 'zigbee2mqtt/Kitchen 3', payload '{"brightness":145,"color":{"x":0.476993298233858,"y":0.413675289942435},"color_temp":400,"linkquality":78,"state":"ON","update":{"state":"idle"},"update_available":false}'
INFO: MQTT publish: topic 'zigbee2mqtt/Kitchen 1', payload '{"brightness":145,"color":{"x":0.476993298233858,"y":0.413675289942435},"color_temp":400,"linkquality":87,"state":"ON","update":{"state":"idle"},"update_available":false}'
INFO: MQTT publish: topic 'zigbee2mqtt/Kitchen', payload '{"brightness":145,"color":{"x":0.476993298233858,"y":0.413675289942435},"color_temp":400,"state":"ON"}'
INFO: MQTT publish: topic 'zigbee2mqtt/Kitchen 2', payload '{"brightness":145,"color":{"x":0.476993298233858,"y":0.413675289942435},"color_temp":400,"linkquality":57,"state":"ON","update":{"state":"idle"},"update_available":false}'
INFO: MQTT publish: topic 'zigbee2mqtt/Kitchen 3', payload '{"brightness":145,"color":{"x":0.476993298233858,"y":0.413675289942435},"color_temp":400,"linkquality":78,"state":"ON","update":{"state":"idle"},"update_available":false}'
INFO: MQTT publish: topic 'zigbee2mqtt/Kitchen 1', payload '{"brightness":144,"color":{"x":0.476993298233858,"y":0.413675289942435},"color_temp":400,"linkquality":87,"state":"ON","update":{"state":"idle"},"update_available":false}'
INFO: MQTT publish: topic 'zigbee2mqtt/Kitchen', payload '{"brightness":144,"color":{"x":0.476993298233858,"y":0.413675289942435},"color_temp":400,"state":"ON"}'
INFO: MQTT publish: topic 'zigbee2mqtt/Kitchen 2', payload '{"brightness":144,"color":{"x":0.476993298233858,"y":0.413675289942435},"color_temp":400,"linkquality":57,"state":"ON","update":{"state":"idle"},"update_available":false}'
INFO: MQTT publish: topic 'zigbee2mqtt/Kitchen 3', payload '{"brightness":144,"color":{"x":0.476993298233858,"y":0.413675289942435},"color_temp":400,"linkquality":78,"state":"ON","update":{"state":"idle"},"update_available":false}'

Does someone has any clue? How can I debug this even further?

ciotlosm commented 3 years ago

Might be better to report this on https://github.com/Koenkk/zigbee2mqtt/issues

ceesvanegmond commented 3 years ago

@ciotlosm Will do; thanks! https://github.com/Koenkk/zigbee2mqtt/issues/6239