I think I have been having a similar problem.
Issue: Tasmota Light/Fan switch appears as Unavailable in Home Assistant quite often (about 5 minutes per hour)
Setup:
- Treatlife DS03 Light Fan Switch Flashed with the Tasmota 9.2.0 (following these directions).
- Wired such that it has power and ground, but light wire and fan wire are caped off (i.e. it controls the light and fan only via WiFi/MQTT
- Home Assistant discovers the switch via the Tasmota (beta) integration.
- I have a fan/Light in the Office attached to Home Assistant using a sonoff ifan03 using this as my guide
- Finally I have them linked via Node Red (I am sure tihs is WAY overcomplicated for the node Red - but I am still new to all this
[{"id":"c060ae7c.770da","type":"tab","label":"Office Light / Fan","disabled":false,"info":""},{"id":"4a314923.8967d8","type":"server-state-changed","z":"c060ae7c.770da","name":"Office Light Switch Changes","server":"c7fbef29.e4f7d","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"light.officelightfanswitch_light","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"x":240,"y":120,"wires":[["35351e43.483702","f368e8e2.4899f8"]]},{"id":"778367ea.c08a78","type":"server-state-changed","z":"c060ae7c.770da","name":"Office Fan Switch Changes","server":"c7fbef29.e4f7d","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"fan.office_fan_switch","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":false,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"x":230,"y":400,"wires":[["d29b25f5.4cfa88"]]},{"id":"251b65f9.61140a","type":"server-state-changed","z":"c060ae7c.770da","name":"Office Light Fan Controller Changes","server":"c7fbef29.e4f7d","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"light.office_light_fan_controller","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"x":260,"y":180,"wires":[["b95a25e2.87f968"]]},{"id":"b76ea93.1e73d58","type":"function","z":"c060ae7c.770da","name":"","func":"msg.payload.service=`turn_${msg.trigger}`;\nmsg.payload.entity=\"light.office_light_fan_controller\";\nmsg.payload.data={\"entity_id\":\"light.office_light_fan_controller\"}\nif (msg.trigger == \"on\") {\n \tmsg.payload.data.brightness=255;\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1060,"y":120,"wires":[["434f82d2.cc336c"]]},{"id":"1f7d48c6.260117","type":"template","z":"c060ae7c.770da","name":"Payload Template","field":"payload","fieldType":"msg","format":"json","syntax":"mustache","template":"{\n \"service\": \"\",\n \"entity\": \"\",\n \"data\":{\n \"entity_id\":\"\"\n }\n}","output":"json","x":890,"y":120,"wires":[["b76ea93.1e73d58"]]},{"id":"35351e43.483702","type":"change","z":"c060ae7c.770da","name":"","rules":[{"t":"set","p":"trigger","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":120,"wires":[["1b117b81.6ddf64"]]},{"id":"434f82d2.cc336c","type":"api-call-service","z":"c060ae7c.770da","name":"Update Office Controller","server":"c7fbef29.e4f7d","version":1,"debugenabled":false,"service_domain":"light","service":"","entityId":"","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1250,"y":120,"wires":[["6e832d02.c434b4","6d5cd269.6e17ec"]]},{"id":"f416fa5.c971108","type":"function","z":"c060ae7c.770da","name":"","func":"msg.payload.service=`turn_${msg.trigger}`;\nmsg.payload.entity=\"light.officelightfanswitch_light\";\nmsg.payload.data={\"entity_id\":\"light.officelightfanswitch_light\"}\nif (msg.trigger == \"on\") {\n \tmsg.payload.data.brightness=255;\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1060,"y":180,"wires":[["44df2576.38912c"]]},{"id":"473bc7a3.004a28","type":"template","z":"c060ae7c.770da","name":"Payload Template","field":"payload","fieldType":"msg","format":"json","syntax":"mustache","template":"{\n \"service\": \"\",\n \"entity\": \"\",\n \"data\":{\n \"entity_id\":\"\"\n }\n}","output":"json","x":890,"y":180,"wires":[["f416fa5.c971108"]]},{"id":"b95a25e2.87f968","type":"change","z":"c060ae7c.770da","name":"","rules":[{"t":"set","p":"trigger","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":180,"wires":[["8e558851.1bc1d8"]]},{"id":"44df2576.38912c","type":"api-call-service","z":"c060ae7c.770da","name":"Update Office Switch","server":"c7fbef29.e4f7d","version":1,"debugenabled":false,"service_domain":"light","service":"","entityId":"","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1240,"y":180,"wires":[["1388a3ab.4230cc"]]},{"id":"fb3dac4d.46477","type":"function","z":"c060ae7c.770da","name":"","func":"msg.payload.service=`turn_${msg.trigger}`;\nmsg.payload.entity=\"fan.office_light_fan_controller\";\nmsg.payload.data.entity_id=\"fan.office_light_fan_controller\";\nif (msg.trigger == \"on\") {\n \tmsg.payload.data.speed=`${msg.speed}`;\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1260,"y":400,"wires":[["9d95f1a5.beb03"]]},{"id":"d29b25f5.4cfa88","type":"change","z":"c060ae7c.770da","name":"","rules":[{"t":"set","p":"trigger","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"speed","pt":"msg","to":"data.new_state.attributes.speed","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":400,"wires":[["97ff6261.4c6b4"]]},{"id":"9d95f1a5.beb03","type":"api-call-service","z":"c060ae7c.770da","name":"Update Office Controller","server":"c7fbef29.e4f7d","version":1,"debugenabled":false,"service_domain":"fan","service":"","entityId":"","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1450,"y":400,"wires":[[]]},{"id":"499b9d2b.0159b4","type":"template","z":"c060ae7c.770da","name":"Payload Template","field":"payload","fieldType":"msg","format":"json","syntax":"mustache","template":"{\n \"service\": \"\",\n \"entity\": \"\",\n \"data\":{\n \"entity_id\": \"\"\n }\n}","output":"json","x":1090,"y":400,"wires":[["fb3dac4d.46477"]]},{"id":"d9a6968c.e97e38","type":"server-state-changed","z":"c060ae7c.770da","name":"Office Light Fan Controller Changes","server":"c7fbef29.e4f7d","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"fan.office_light_fan_controller","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":false,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"x":260,"y":460,"wires":[["463be1e6.91f7c"]]},{"id":"463be1e6.91f7c","type":"change","z":"c060ae7c.770da","name":"","rules":[{"t":"set","p":"trigger","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"speed","pt":"msg","to":"data.new_state.attributes.speed","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":460,"wires":[["fe4c1dba.f711e"]]},{"id":"6a040859.2a9398","type":"function","z":"c060ae7c.770da","name":"","func":"msg.payload.service=`turn_${msg.trigger}`;\nmsg.payload.entity=\"fan.office_fan_switch\";\nmsg.payload.data.entity_id=\"fan.office_fan_switch\";\nif (msg.trigger == \"on\") {\n \tmsg.payload.data.speed=`${msg.speed}`;\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1260,"y":460,"wires":[["1e89c450.916dbc"]]},{"id":"1e89c450.916dbc","type":"api-call-service","z":"c060ae7c.770da","name":"Update Office Switch","server":"c7fbef29.e4f7d","version":1,"debugenabled":false,"service_domain":"fan","service":"","entityId":"","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1440,"y":460,"wires":[[]]},{"id":"de862b54.3933d8","type":"template","z":"c060ae7c.770da","name":"Payload Template","field":"payload","fieldType":"msg","format":"json","syntax":"mustache","template":"{\n \"service\": \"\",\n \"entity\": \"\",\n \"data\":{\n \"entity_id\": \"\"\n }\n}","output":"json","x":1090,"y":460,"wires":[["6a040859.2a9398"]]},{"id":"1b117b81.6ddf64","type":"api-current-state","z":"c060ae7c.770da","name":"Light states !=","server":"c7fbef29.e4f7d","version":1,"outputs":2,"halt_if":"payload","halt_if_type":"msg","halt_if_compare":"is_not","override_topic":false,"entity_id":"light.office_light_fan_controller","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":700,"y":120,"wires":[["1f7d48c6.260117"],[]]},{"id":"8e558851.1bc1d8","type":"api-current-state","z":"c060ae7c.770da","name":"Light states !=","server":"c7fbef29.e4f7d","version":1,"outputs":2,"halt_if":"payload","halt_if_type":"msg","halt_if_compare":"is_not","override_topic":false,"entity_id":"light.officelightfanswitch_light","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":700,"y":180,"wires":[["473bc7a3.004a28"],[]]},{"id":"97ff6261.4c6b4","type":"api-current-state","z":"c060ae7c.770da","name":"Fan Controller State","server":"c7fbef29.e4f7d","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"fan.office_light_fan_controller","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":720,"y":400,"wires":[["8d0e094c.8a8608"]]},{"id":"fe4c1dba.f711e","type":"api-current-state","z":"c060ae7c.770da","name":"Fan Switch State","server":"c7fbef29.e4f7d","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"fan.office_fan_switch","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":710,"y":460,"wires":[["b53c236b.550d4"]]},{"id":"8d0e094c.8a8608","type":"function","z":"c060ae7c.770da","name":"","func":"if((msg.trigger != msg.data.state) || (msg.speed != msg.data.attributes.speed)){\n return msg; \n}","outputs":1,"noerr":0,"initialize":"","finalize":"","x":920,"y":400,"wires":[["499b9d2b.0159b4"]]},{"id":"b53c236b.550d4","type":"function","z":"c060ae7c.770da","name":"","func":"if((msg.trigger != msg.data.state) || (msg.speed != msg.data.attributes.speed)){\n return msg; \n}","outputs":1,"noerr":0,"initialize":"","finalize":"","x":920,"y":460,"wires":[["de862b54.3933d8"]]},{"id":"8467a7d5.9e8938","type":"comment","z":"c060ae7c.770da","name":"Office Light Sync","info":"","x":200,"y":80,"wires":[]},{"id":"d3dbfda5.7c5bd","type":"comment","z":"c060ae7c.770da","name":"Office Fan Sync","info":"","x":200,"y":360,"wires":[]},{"id":"1388a3ab.4230cc","type":"change","z":"c060ae7c.770da","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"trigger","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1460,"y":180,"wires":[["1b117b81.6ddf64"]]},{"id":"6e832d02.c434b4","type":"change","z":"c060ae7c.770da","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"trigger","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1460,"y":120,"wires":[["8e558851.1bc1d8"]]},{"id":"f368e8e2.4899f8","type":"debug","z":"c060ae7c.770da","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":490,"y":80,"wires":[]},{"id":"6d5cd269.6e17ec","type":"debug","z":"c060ae7c.770da","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1430,"y":80,"wires":[]},{"id":"c7fbef29.e4f7d","type":"server","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]
When I look at the tasmota console, I noticed that the switch appeared to reset around the same time it went unavailable in Home Assistant (First time noticing this)
Console Output:
00:00:00 CFG: Loaded from flash at F6, Count 206
00:00:00 QPC: Count 1
00:00:00 SNS: Hardware Serial
00:00:00 Project tasmota Tasmota Version 9.2.0(tasmota)-2_7_4_9(2020-12-17T10:05:31)
00:00:00 WIF: Connecting to AP1 <SSID> Channel 11 BSSId D4:5D:64:EC:9D:C0 in mode 11n as OfficeLightFanSwitch...
00:00:02 WIF: Connected
00:00:02 HTP: Web server active on OfficeLightFanSwitch with IP address 192.168.1.###
17:37:27 MQT: Attempting connection...
17:37:28 MQT: Connected
17:37:28 MQT: tele/tasmota_office-ds03/LWT = Online (retained)
17:37:28 MQT: cmnd/tasmota_office-ds03/POWER =
17:37:28 MQT: tele/tasmota_office-ds03/INFO1 = {"Module":"Tuya MCU","Version":"9.2.0(tasmota)","FallbackTopic":"cmnd/DVES_7F64AC_fb/","GroupTopic":"cmnd/tasmotas/"}
17:37:28 MQT: tele/tasmota_office-ds03/INFO2 = {"WebServerMode":"Admin","Hostname":"OfficeLightFanSwitch","IPAddress":"192.168.1.###"}
17:37:28 MQT: tele/tasmota_office-ds03/INFO3 = {"RestartReason":{"Exception":29,"Reason":"Exception","EPC":["4000df64","00000000","00000000"],"EXCVADDR":"00000000","DEPC":"00000000","CallChain":["40102ad9","40101494","40260de7","40105943","40260d7c","40260d23","4025fe80","4025fea9","4025d914","4024e961","40259c7d","4024ecd9","4025e60b","40000f3d","4025e07e","402677cf","4026708f","40245084","40000f49","40000f49","40000e19","40105a61","40105a67","4010000d","40265f78","40265f29","4010595b","4010323f","40100a40","40103420","4010595b"]}}
17:37:28 MQT: stat/tasmota_office-ds03/RESULT = {"POWER1":"OFF"}
17:37:28 MQT: stat/tasmota_office-ds03/POWER1 = OFF
17:37:28 MQT: stat/tasmota_office-ds03/RESULT = {"POWER2":"OFF"}
17:37:28 MQT: stat/tasmota_office-ds03/POWER2 = OFF
17:37:28 TYA: MCU Product ID: {"p":"ipyqwvhvzzjezv35","v":"3.3.14","m":0}
17:37:28 RUL: TUYARECEIVED#DATA=55AA03070005030400010016 performs "publish2 stat/tasmota_office-ds03/speed 3,0"
17:37:28 MQT: stat/tasmota_office-ds03/speed = 3,0 (retained)
17:37:29 MQT: tele/tasmota_office-ds03/STATE = {"Time":"2020-12-28T17:37:29","Uptime":"0T00:00:07","UptimeSec":7,"Heap":26,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":55,"MqttCount":1,"POWER1":"OFF","POWER2":"OFF","Dimmer":100,"Fade":"OFF","Speed":1,"LedTable":"OFF","Wifi":{"AP":1,"SSId":"<SSID>","BSSId":"D4:5D:64:EC:9D:C0","Channel":11,"RSSI":100,"Signal":-43,"LinkCount":1,"Downtime":"0T00:00:04"}}
17:37:29 MQT: stat/tasmota_office-ds03/RESULT = {"Time":"2020-12-28T17:37:29","Uptime":"0T00:00:07","UptimeSec":7,"Heap":26,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":55,"MqttCount":1,"POWER1":"OFF","POWER2":"OFF","Dimmer":100,"Fade":"OFF","Speed":1,"LedTable":"OFF","Wifi":{"AP":1,"SSId":"<SSID>","BSSId":"D4:5D:64:EC:9D:C0","Channel":11,"RSSI":100,"Signal":-43,"LinkCount":1,"Downtime":"0T00:00:04"}}
17:37:29 MQT: stat/tasmota_office-ds03/STATUS = {"Status":{"Module":54,"DeviceName":"Tasmota","FriendlyName":["Tasmota","Tasmota2"],"Topic":"tasmota_office-ds03","ButtonTopic":"0","Power":0,"PowerOnState":3,"LedState":1,"LedMask":"FFFF","SaveData":1,"SaveState":1,"SwitchTopic":"0","SwitchMode":[0,0,0,0,0,0,0,0],"ButtonRetain":0,"SwitchRetain":0,"SensorRetain":0,"PowerRetain":0}}
17:37:29 MQT: stat/tasmota_office-ds03/STATUS1 = {"StatusPRM":{"Baudrate":115200,"SerialConfig":"8N1","GroupTopic":"tasmotas","OtaUrl":"http://ota.tasmota.com/tasmota/release/tasmota.bin.gz","RestartReason":"Exception","Uptime":"0T00:00:07","StartupUTC":"2020-12-28T16:37:22","Sleep":50,"CfgHolder":4617,"BootCount":30,"BCResetTime":"2020-12-18T02:29:38","SaveCount":206,"SaveAddress":"F6000"}}
17:37:29 MQT: stat/tasmota_office-ds03/STATUS11 = {"StatusSTS":{"Time":"2020-12-28T17:37:29","Uptime":"0T00:00:07","UptimeSec":7,"Heap":26,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":56,"MqttCount":1,"POWER1":"OFF","POWER2":"OFF","Dimmer":100,"Fade":"OFF","Speed":1,"LedTable":"OFF","Wifi":{"AP":1,"SSId":"<SSID>","BSSId":"D4:5D:64:EC:9D:C0","Channel":11,"RSSI":100,"Signal":-47,"LinkCount":1,"Downtime":"0T00:00:04"}}}
17:37:30 QPC: Reset
17:37:32 MQT: tele/tasmota_office-ds03/STATE = {"Time":"2020-12-28T17:37:32","Uptime":"0T00:00:10","UptimeSec":10,"Heap":26,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":1,"POWER1":"OFF","POWER2":"OFF","Dimmer":100,"Fade":"OFF","Speed":1,"LedTable":"OFF","Wifi":{"AP":1,"SSId":"<SSID>","BSSId":"D4:5D:64:EC:9D:C0","Channel":11,"RSSI":100,"Signal":-43,"LinkCount":1,"Downtime":"0T00:00:04"}}
17:42:32 MQT: tele/tasmota_office-ds03/STATE = {"Time":"2020-12-28T17:42:32","Uptime":"0T00:05:10","UptimeSec":310,"Heap":23,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":1,"POWER1":"OFF","POWER2":"OFF","Dimmer":100,"Fade":"OFF","Speed":1,"LedTable":"OFF","Wifi":{"AP":1,"SSId":"<SSID>","BSSId":"D4:5D:64:EC:9D:C0","Channel":11,"RSSI":100,"Signal":-42,"LinkCount":1,"Downtime":"0T00:00:04"}}
17:47:32 MQT: tele/tasmota_office-ds03/STATE = {"Time":"2020-12-28T17:47:32","Uptime":"0T00:10:10","UptimeSec":610,"Heap":24,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":1,"POWER1":"OFF","POWER2":"OFF","Dimmer":100,"Fade":"OFF","Speed":1,"LedTable":"OFF","Wifi":{"AP":1,"SSId":"<SSID>","BSSId":"D4:5D:64:EC:9D:C0","Channel":11,"RSSI":100,"Signal":-42,"LinkCount":1,"Downtime":"0T00:00:04"}}
17:52:32 MQT: tele/tasmota_office-ds03/STATE = {"Time":"2020-12-28T17:52:32","Uptime":"0T00:15:10","UptimeSec":910,"Heap":23,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":34,"MqttCount":1,"POWER1":"OFF","POWER2":"OFF","Dimmer":100,"Fade":"OFF","Speed":1,"LedTable":"OFF","Wifi":{"AP":1,"SSId":"<SSID>","BSSId":"D4:5D:64:EC:9D:C0","Channel":11,"RSSI":100,"Signal":-41,"LinkCount":1,"Downtime":"0T00:00:04"}}