MQTT Fan and Light

So I am sure this has already been covered, but i havent found any solutions yet, but I have a ceiling fan that is controlled by a remote that can change the speeds, turn the fan off, and toggle the light. I have an SDR setup to listen for any remote actions and what button is pressed is passed as the value of ‘button’. A few problems i want to solve:

  1. How should i go about trying to store the state of the light since we cant query the device for the light state and the light button is simply a toggle? Retain: true doesnt appear to actually retain the state.

  2. I want the fan listed as off obviously the fan_off button is selected and if its on, to display the speed that is set.

  3. If i do a basic entity card with the fan, since the speeds are provided and it knows its a fan, aren’t the fan speeds typically available as a drop down within the entities details?

Possible button values: fan_high, fan_med, fan_low, fan_off, light

Here is what i have so far that obviously isnt fully working yet. Ignore the command part as I am not to that part of the project yet. LOL.

fan:
  - platform: mqtt
    name: "Master Bedroom Fan"
    state_topic: "homeassistant/master_fan/button"
    command_topic: "homeassistant/master_fan/button/command"
    state_value_template: "{% if value != 'light' %}{{value}}{% endif %}"
    payload_on: "fan_low"
    payload_off: "fan_off"
    payload_low_speed: "fan_low"
    payload_medium_speed: "fan_med"
    payload_high_speed: "fan_high"
    speeds:
      - low
      - medium
      - high
    retain: true

and for the light, i put it as a switch:

switch:
  - platform: mqtt
    name: "Master Bedroom Fan Light"
    state_topic: "homeassistant/master_fan/button"
    command_topic: "homeassistant/master_fan/button/command"
    #state_value_template: "{% if value == 'light' %}{{value}}{% endif %}"
    retain: true