Two Inputs for Device State

Device will publish state of sensor after receiving a command.
How to determine initial sensor state when HA state is Unknown?

Device also publishes TELEMETRY that includes sensor state.

Can not poll sensor status on demand.

How to update device state using both MQTT state and Telemetry topics?

It would be nice if there were an OR function to set device state.

Device State = stat/sensor/state or tele/sensor/state

I am a Newbie so examples are most helpful. Response like build an automation…not so much helpful.


Details:
Sonoff Basic running Tasmota
MQTT
Main relay controls garage door: cmnd/garage/POWER
Reed relay determines door position connected to GPIO14:

Issuing command cmnd/garage/POWER ON will move door and device will publish GPIO14 state with cmnd/sensor/POWER1 ON/OFF

When HA restarts GPIO14 state unknown unless command issued.

If this happens state may be determined by using regular telemetry published from device tele/garage/sensor using json.

How to use this state to update unknown for state topic cmnd/sensor/POWER1