I need help with automation to reload localtuya

Hi everyone.

I’m having some trouble with my home wifi, therefore when tuya devices drop out of wifi and reconnect, they become unavaliable in HA.

Until we solve wifi problems, could someone help me with how to set up an automation, which would Reload localtuya once any of devices becomes unavaliable?

Here’s the basic principle:

alias: example
trigger:
  - platform: template 
    value_template: >
      {{ expand('light.your_tuya_light, 'switch.your_tuya_switch')
        | selectattr('state', 'eq', 'unavailable') | list | count > 0 }}
condition: []
action:
  - service: homeassistant.reload_config_entry
    data:
      entry_id: "{{ config_entry_id('light.any_of_your_tuya_entities') }}"

In the Template Trigger’s value_template, enter the entity_id’s of all of the Tuya entities you want to monitor in the expand() function.

In the service call’s entry_id, enter the entity_id of any one of your Tuya entities in the config_entry_id() function.

Thank you so much, i will try tomorrow. I’m very new to all this, although i managed to setup all the stuff and flashed few esp’s. But programming is not something i am good at :slight_smile:

Appreciate it!

Any progress to report?