SOLVED: Zigbee2MQTT configuration for IKEA tradfri lights

Hi guys. I am unsure how to control my coupled IKEA tradfri lights.

I coupled them correctly using the example for pairing.

2018-12-19 20:27:14 - info: New device with address 0xd0cf5efffe18a77d connected!
2018-12-19 20:27:14 - info: MQTT publish: topic 'zigbee2mqtt/bridge/log', payload '{"type":"device_connected","message":"0xd0cf5efffe18a77d"}'
2018-12-19 20:27:14 - info: MQTT publish: topic 'homeassistant/light/0xd0cf5efffe18a77d/light/config', payload '{"brightness":true,"color_temp":true,"schema":"json","command_topic":"zigbee2mqtt/0xd0cf5efffe18a77d/set","state_topic":"zigbee2mqtt/0xd0cf5efffe18a77d","availability_topic":"zigbee2mqtt/bridge/state","name":"0xd0cf5efffe18a77d_light","unique_id":"0xd0cf5efffe18a77d_light_zigbee2mqtt","device":{"identifiers":"zigbee2mqtt_0xd0cf5efffe18a77d","name":"0xd0cf5efffe18a77d","sw_version":"Zigbee2mqtt 1.0.1","model":"TRADFRI LED bulb GU10 400 

I can control the light with custom topics in the developer part of Home Assistant, like so:

topic%20works

But if i plug this (picture below) in the configuration.yaml, it does not work in the interface. it is not even recognized… Note that the Sonoff switch does work. What could be the problem?

edit: When I turn the light off with the custom control, I can turn them on through the front interface, but can not turn them off. What could be the reason?

Does anyone have a solution here? It seems like the biggest problem is that HomeAssistant can not understand the state topic.

Putting some keywords: GU10, zigbee, unsolved

As requested the code I’m currently using:

light:
  - platform: mqtt
    name: "Ikea Spot 1"
    command_topic: "zigbee2mqtt/ikea_spot_1/set"
    state_topic: "zigbee2mqtt/ikea_spot_1"
    availability_topic: "zigbee2mqtt/bridge/state"
    brightness: true
    color_temp: true
    schema: json

This does give me the option to turn the light on, which it does. But then the interface does not recognize it. Also, it does not give an option to set the brightness or the color_temp.

When I’m watching the state_topic on an external mqtt watcher I do see it does post the differences, so I think it is the correct topic.

So, zigbee2mqtt/ikea_spot_1 tells me: {"state":"ON","brightness":100,"color_temp":400}.

On the discord channel @tinkerer told me that:

That’s a JSON payload containing the state, not the actual state, that’s the problem

How do I fix this?

Hi, I can not see anything wrong. You have told HA to use json (schema: json). Are you running Hassbian or Hass.io? I am using Hassbian and that makes it fairly easy to debug to check if the light is properly connected in zigbee2mqtt. A easy way is to subscribe to all mqtt messages and see if zigbee2mqtt have sent a proper config message to HA. Here is an example:
homeassistant/light/0x000b57fffe8cc3f5/light/config {“brightness”:true,“schema”:“json”,“command_topic”:“zigbee2mqtt/0x000b57fffe8cc3f5/set”,“state_topic”:“zigbee2mqtt/0x000b57fffe8cc3f5”,“availability_topic”:“zigbee2mqtt/bridge/state”,“name”:“0x000b57fffe8cc3f5_light”,“unique_id”:“0x000b57fffe8cc3f5_light_zigbee2mqtt”,“device”:{“identifiers”:“zigbee2mqtt_0x000b57fffe8cc3f5”,“name”:“0x000b57fffe8cc3f5”,“sw_version”:“Zigbee2mqtt 1.0.1”,“model”:“TRADFRI LED bulb E12/E14/E17 400 lumen, dimmable warm white, chandelier opal (LED1649C5)”,“manufacturer”:“IKEA”}}

I’ve had the exact same problem but luckily after some research managed to find a solution.

Try adding ‘optimistic: true’ to your configuration.yaml (also schema and platform don’t require " " but not sure if this is a semantics thing or would actually break functionality)

Thanks for your solution Sloth! When looking at some help they say:

When a state topic is not available, the light will work in optimistic mode. In this mode, the light will immediately change state after every command. Otherwise, the light will wait for state confirmation from the device (message from state_topic ).

By using this optimistic mode, don’t you just basically remove feedback? So when Zigbee2MQTT screws up you don’t know it?

Does it also keep all options: does your homeassistant instance let you change brightness as well?

I must say I can not test it right now, will do so when I get home.

I’m new with Zigbee2MQTT and still troubleshooting with the coverage etc, but your remark/concern seems valid.
I created a group of 4 Tradfri lights. When I turn the entire group on or off, some lights will not turn on or off.

When this happens, obviously the lamp state of the HA user interface does not match the real-life state. This of course is something that I’d wish to avoid.

Also I can’t change brightness or color temperature of my lights when I click on the bulb icon, this is also something I’d have to look into.

Yup, it shows shomething very similar. For the MQTT topic homeassistant/light/0xd0cf5efffe18a77d/light/config it publishes

{"brightness":true,"color_temp":true,"schema":"json","command_topic":"zigbee2mqtt/ikea_spot_1/set","state_topic":"zigbee2mqtt/ikea_spot_1","availability_topic":"zigbee2mqtt/bridge/state","name":"ikea_spot_1_light","unique_id":"0xd0cf5efffe18a77d_light_zigbee2mqtt","device":{"identifiers":"zigbee2mqtt_0xd0cf5efffe18a77d","name":"ikea_spot_1","sw_version":"Zigbee2mqtt 1.0.1","model":"TRADFRI LED bulb GU10 400 lumen, dimmable, white spectrum (LED1537R6)","manufacturer":"IKEA"}}

And this is my MQTT configuration

mqtt:
  broker: core-mosquitto
  username: !secret mosquitto_login
  password: !secret mosquitto_pass
  discovery: true  
  discovery_prefix: homeassistant # 'homeassistant' is default
  birth_message:
    topic: 'hass/status'
    payload: 'online'
  will_message:
    topic: 'hass/status'
    payload: 'offline'

It works as in I can turn them on or off, but it loses a lot of functionality in my opinion in this way. There must be a better solution…

In the picture below, all lights are turned on. The first light is configured with optimistic: true and the 2nd and 3rd light by the autodiscovery of MQTT in HASSio. They also can not read the state of the lights, so they won’t acknowledge it is on. Currently none of these lights has the function to change brightness or warmth…

all_turned_on

SOLVED

For MQTT autodiscovery, you have to be at least on HomeAssistant 0.84. So upgrade and enjoy!

old link:
https://koenkk.github.io/zigbee2mqtt/integration/home_assistant.html

new link:


edit: so delete everything you did in configuration.yaml and let autodiscovery do the work!
2 Likes

Thank you, I updated to 0.84.6 and can now reliably use zigbee2mqtt using autodiscovery :grinning:

I did spend some time troubleshooting error “Data in your config entry is going to override your configuration.yaml”

Solution for this: remove any mqtt: entries from your configuration.yaml and use the embedded mqtt component from home assistant.

1 Like