DW2-WiFi switch issues

All the latest updates have rendered the DW2-WiFi switch from Sonoff almost completely unusable.
I have noticed however the only entity that does still work is the binary_sensor_lock, which you can still use in automations.

I also found a little trick to set the binary state of the DW2 door open/closed, so that you can use the entity that doesn’t work
This also might be of use in some other scenarios, where the the entity has become unavailable.

Go to the Config folder
Put the following in the config file python_script:
Put a folder in the config folder python_scripts
Put a file called set_state.py in the python_scripts folder
Restart HA

In Automations you can use the python script to set the state as this example

  - service: python_script.set_state
      entity_id: binary_sensor.sonoff_1001429a3d
      state: "on"