MQTT for everything (control switches/sensors/...)

There was this Blogpost about a simple way to create an web application which is connected to a Home-Assistant server using the MQTT Eventstream. I want to make a very simple Kivy application for the Raspberry Pi touch screen and I need a similar solution for this project. But instead of using the whole MQTT Eventstream I would like to configure only specifig sensors and switches to MQTT (without JSON format).

Something like this:

switch:
    platform: rpi_gpio
    ports:
        11: Fan Office
        mqtt: home/switches/raspberrypi/fan_office

binary_sensor:
  platform: rpi_gpio
  ports:
    11: PIR Office
    mqtt: home/sensors/raspberrypi/pir_office

Using my Kivy application I will then connect to the Hass MQTT broker and read/change the topics to control my hass-server

I suggest you have a look at my Server-sent events example which is somehow the improved version of the idea with the MQTT Eventstream.

Or the Home Assistant REST API which let you choose what entities to include.

yes, the RestAPI would be an option since I also want to control switches (not just display the state). I thought that MQTT would be a leightweight and smart way to communicate with an app. In addition it has the benefit that I don’t need to open any ports on my router (I’m using Cloudmqtt as my broker).