Switch.toggle crashes integration

Hi,

I ran into a weird problem with the mysensors integration. I am running HA 0.107.1.

What I would like to achieve:

I would like to trigger different automations (via appdaemon) by pressing buttons on my TV remote.

What I have so far:

I built the infrared sensor and it sends messages to my gateway, which connects to Home Assistant. I can remotely control kodi and my xiaomi-light.

Encountered but worked around issues:

I can’t use a “state change” to trigger my automations abecause that would mean I can’t send the same infrared code twice (because no state change takes place then). I worked around that by using events.

The issue with events is that about every 15 min the mysensors-integration rereads the last value sents and issues a new event. That triggers the last automation again. To work around that I configured the IR-sensor to send the IR-code and right after that a message containing the IR-code “0”. That way I can filter those events out.

Issue I am stuck with:

The mysensors-integration gets stuck when toggling my tasmota-flashed plug (via MQTT). I can toggle the plug once just fine, but then HA doesn’t react to any input and the logs show no messages received by the mysensors gateway.

This happens in appdaemon and when writing an automation in HA.

Automation:

alias: 'Infrared Debug'
trigger:
  platform: state
  entity_id: sensor.mysensors_wohnzimmer_main_3_3
condition:
- condition: template
  value_template: "{{ not is_state('trigger.to_state.state', '0') }}"
action:
  - service: system_log.write
    data_template:
      message: >
              "Automation IR Debug: {{trigger.to_state.state}}"
      level: warning
      - service: switch.toggle
      entity_id: switch.kleine_lampe

Log-output:

2020-04-17 22:19:13 DEBUG (MainThread) [mysensors.handler] n:0 c:255 t:3 s:9 p:173414 TSF:MSG:READ,3-3-0,s=3,c=1,t=33,pt=5,l=4,sg=0:551507370
2020-04-17 22:19:13 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 3 child 3
2020-04-17 22:19:13 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: mysensors_wohnzimmer_main 3 3: value_type 33, value = 551507370
2020-04-17 22:19:13 WARNING (MainThread) [homeassistant.components.system_log.external] "Automation IR Debug: 551507370"
2020-04-17 22:19:13 DEBUG (MainThread) [mysensors.handler] n:0 c:255 t:3 s:9 p:173574 TSF:MSG:READ,3-3-0,s=3,c=1,t=33,pt=2,l=2,sg=0:0
2020-04-17 22:19:13 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 3 child 3
2020-04-17 22:19:13 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: mysensors_wohnzimmer_main 3 3: value_type 33, value = 0
2020-04-17 22:19:13 WARNING (MainThread) [homeassistant.components.system_log.external] "Automation IR Debug: 0"
2020-04-17 22:19:18 DEBUG (SyncWorker_14) [mysensors.persistence] Saving sensors to persistence file /config/mysensors1.pickle

After that no new button-presses/IR-codes are received until I restart Home Assistant or some minutes go by (about 15).

It seems there is an issue with my automation since it doesn’t filter the “0”-message, so If anybody has an idea I’d be grateful.

Can anybody tell me how to debug the overall issue further or what I am doing wrong? This doesn’t happen with the xiaomi-light, but only with the plug. Is this possibly an MQTT-issue? A tasmota-problem? After the mysensors-integration freezes I can still toggle the switch from HA.