Listen_event is only reporting state_changed events

I used to be able to subscribe to received mqtt messages on the event bus with

        self.listen_event(self.valve_state_event, "mqtt_message_received", topic=self.valve_state_topic)

but I noticed my slider wasn’t updating, and I discovered that this callback was not being called. If I changed the call to receive all events like

    self.listen_event(self.valve_state_event)

The only events that are seen in the callback are state_changed events, even if I send mqtt messages into the system. Are mqtt messages on the event bus now?

I’m not sure when this started happening, as I only use it to update the UI, so it could be several HA releases ago.

i have no MQTT but i get only 3 kind of events.

  • state_changed
  • service_executed
  • call_service

Yes, a bit more fiddling around, and I saw some of those events as well, but no mqtt messages.

I poked around the HA code a bit and it seems that mqtt messages are sent by some dispatcher now, rather than the event bus, so I am going to have to rewrite some code.

Hi gpbenton, how did you resolve this? Thx!

Its some time ago now, but I think I created sensors that receive each mqtt message, and then trigger on the state of the sensor.

It involves a slight increase in processing before the callback is received, but I have not noticed any practical problems with it.

2 Likes