Mqtt_eventstream + zha light

I’m debugging an issue with mqtt_eventstream and zha lights, when I try to turn on/off a light from a remote instance nothing happen, so I started to debug, customizing some components and adding more logging… and now I’m seeing some really weird behavior, here a extract of the log when I try to turn off from remote hassio:

2019-05-30 00:32:41 INFO (MainThread) [custom_components.mqtt] Received message on primary/eventstream: b'{"event_type": "call_service", "event_data": {"domain": "light", "service": "turn_off", "service_data": {"entity_id": "light.sengled_e11_g13_031212df_1"}}}'
2019-05-30 00:32:41 INFO (MainThread) [custom_components.mqtt] Match: Subscription(topic='primary/eventstream/#', callback=<function async_setup.<locals>._event_receiver at 0x733848e8>, qos=0, encoding='utf-8')
2019-05-30 00:32:41 INFO (MainThread) [custom_components.mqtt_eventstream] _event_receiver
2019-05-30 00:32:41 INFO (MainThread) [custom_components.mqtt_eventstream] async_fire: call_service, {'domain': 'light', 'service': 'turn_off', 'service_data': {'entity_id': 'light.sengled_e11_g13_031212df_1'}}
2019-05-30 00:32:41 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=light, service=turn_off, service_data=entity_id=light.sengled_e11_g13_031212df_1>
  1. the message is received by mqtt and passed to mqtt_eventstream
  2. mqtt_eventstream async fires a call_service, with the proper payload
  3. homeassistant.core handle the event, and thats all the log that core has…
  4. nothing more, light still on

But now here is a direct turn_off from the local homeassistant:

2019-05-30 00:32:54 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=light, service=turn_off, service_data=entity_id=light.sengled_e11_g13_031212df_1>
2019-05-30 00:32:54 DEBUG (MainThread) [custom_components.zha.light] light.sengled_e11_g13_031212df_1: async_turn_off
2019-05-30 00:32:54 DEBUG (MainThread) [custom_components.zha.core.channels] 0xf9e1:1:0x0006: executed command: off with args: () with kwargs: {} and result: [0, <Status.SUCCESS: 0>]
2019-05-30 00:32:54 DEBUG (MainThread) [custom_components.zha.light] light.sengled_e11_g13_031212df_1: turned off: True
  1. core directly get the event, and handle it
  2. zha.light async_turn_off gets called
  3. the light turn off…

In the first case everything runs fine until step 3, that step looks the same as step 1 on the second example… so, why the first one just stop there? Event looks the same, payload too… whats wrong? what am I missing?

BTW, any chance to put a pdb into the core?.. logging doesn’t looks enough… and BTW, why so little debug messages? I expect debug to be really verbose and tell me what is going on step by step…

thanks in advance!

I can’t help with the specific question you have but something that might help is that I’ve looked at both event stream and state stream and found that state stream was much more straightforward than event stream.

Maybe you could try that and it might solve your problem that way.

Thanks for your response, but if I don’t miss understand mqtt_statestream requires more configuration, I should add the lights on the remote hassio and an automation to control the lights from the mqtt payload.
BTW, I was doing some extra debugging and found that mqtt_eventstream is working with a yeelight, the main difference is that yeelight don’t use async, so looks like is basically a problem with zha.light implementation.

yes, that’s my understanding.

But I think you would have to do something similar with event stream too if I’m not mistaken (again, not much experience with either of them…).

and you can easily specify which devices you want to include/exclude instead of listening for every event.

Ok, I give up on this… mqtt_eventstream is too unstable, I switched to statestream and a bunch of automations…
I’ll try to fix it when I have more knowledge about home-assistant components development.