Home Assistant + Xiaomi Yeelight + MQTT

Hello!

I am veeeery new in smart home topic and I can’t find a solution for task that I want to solve.

I have Raspberry Pi with installed Home Assistant, connected to this OS Xiaomi Yeelight WiFi Bulb (it works perfectly from UI interface) and account on CloudMQTT broker. I correctly connected my Home Assistant to this broken (I can see active connection).
Also I’ve developed small web application that also can connect via websockets to the broken, subscribe on topics and publish messages to topics.

My question is: how to set up home assistant so it will listen to messages from some topic on MQTT broker and change state of this light? For example I post from my application message “/kitchen/light off” and this light is set to off mode. Is that possible?

I will be very appreciate for your help!

I’ve decided to use automations with mqtt triggers and now it works correctly with this type of setup

  • id: light-mqtt-turn-on
    alias: Kitchen Light MQTT Turn On
    trigger:
    platform: mqtt
    topic: /home/light
    payload: “on”
    encoding: “utf-8”
    action:
    service: light.turn_on
    entity_id: light.kitchen

  • id: light-mqtt-turn-off
    alias: Kitchen Light MQTT Turn Off
    trigger:
    platform: mqtt
    topic: /home/light
    payload: “off”
    encoding: “utf-8”
    action:
    service: light.turn_off
    entity_id: light.kitchen

Can you help me to understand if it is possible to make this kind of messages in this chain “hass - mqqt broker - web app”

I send from webapp something like /home/light status and home assistant returns status (on or off) on my light?

Thanks!