MQTT export component

The MQTT export component is a custom component which is sending all states and some details in one MQTT message.

Put the file file in the folder custom_components of your local Home Assistant configuration folder .homeassistant.

Your configuration.yaml file needs an entry for the component including the publishing topic (publish_topic).

  publish_topic: "home/states"

Sample output:

          "location_name":"Test room",
                "friendly_name":"Bathroom window",
             "last_updated":"14:10:57 06-04-2016",
             "last_changed":"14:10:57 06-04-2016"
                "next_setting":"18:06:45 06-04-2016",
                "next_rising":"04:56:02 07-04-2016",
             "last_updated":"14:11:30 06-04-2016",
             "last_changed":"14:11:09 06-04-2016"



Why is this not a official component?
Have been working on my own export component, then I suddenly found this. Think I had found it earlier if it was official.

How to get data and create new topic?

Subscribe to the topic you stated in the configuration.

I did, but how to extract data for each state and have a topic for each state

{“states”: [{“state”: “off”, “attributes”: {“battery_level”: 53, “friendly_name”: “Motion sensor kitchen”, “No motion since”: “1200”, “device_class”: “motion”}, “last_changed”: “2017-05-13T21:18:27.634595+00:00”, “entity_id”: “binary_sensor.motion_sensor_158d000127acc3”, “last_updated”: “2017-05-13T21:37:17.988026+00:00”}, {“state”: “scening”, “attributes”: {“entity_id”: [“group.livingroom_lights”], “friendly_name”: "White


Yep, understand, although too complicated for me.

I wonder if anyone can help do an example (using the above usage case).

Most important feature, for me now, is to know if the entity_id (light and switch) is ON or OFF

Perhaps you tell us what you want to archive exactly? A list of entities and their states? If so, then it’s still about parsing the MQTT payload.

all topic like

and so on.

For the state, I understand I will need to subscribe to the topic created, but I do not have to create all topics in HASS (mqtt.publish for each entity_id)

I hope I am clear (and I hope it make sense what I want :smile:)

Is there a way to force trigger to send all again?

If I restart my main hass I could publish something that resend all from secondary hass with mqtt_export