Tasmotised sonoff connection Issues

I have several tasmotised sonoff switches connected to hassio running on my Orange Pi. Among them a few are manually configured and in these i am facing a small issue. After i restart hassio server or reboot the system, hassio fails to obtain the working state of the switch.i,e even when the switch is on, hassio wont show it in the UI. it needs me to manually switch on the switch from hassio for the first time to get the state detection back to normal working. Can anybody help .-

  • name: Shemin Bedroom Fan
    platform: mqtt
    state_topic: stat/sonoff1bac/POWER
    state_on: “ON”
    state_off: “OFF”
    command_topic: cmnd/sonoff1bac/POWER
    payload_on: ON
    payload_off: OFF
    availability_topic: tele/sonoff1bac/LWT
    payload_available: Online
    payload_not_available: Offline
    qos: 2
    I have also enabled setoption59 on tasmota

Try this automation, that I got from someone else. Every reboot it will check the initial state.

  - id: sonoffstart
    alias: Power State Sonoff on HA Start-Up
    - event: start
      platform: homeassistant
    - data:
        payload: ''
        topic: sonoffs/cmnd/state
      service: mqtt.publish
    initial_state: 'true'

Cool man…that fixed it…thanks