Zigbee2Tasmota Light Unknown State

I have a few Zigbee devices going through a Sonoff switch flashed with Tasmota. I originally used ZHA but ran into issues where devices would go offline and require a reset. I read that using Zigbee2Tasmota would resolve those issues and so far it’s worked well.

Today I added a few Zigbee light bulbs. I was able to set them up as switches relatively easily but then I couldn’t control their brightness. I switched them to lights and now am unable to read the state. I just get Unknown. Here is what I have in configuration.yaml:

light:
  - platform: mqtt
    name: "Basement Light Bulb 1"
    state_topic: "tele/Zigbee/Basement_Light_Bulb_1/SENSOR"
    state_value_template: "{{ value_json['ZbReceived']['Basement_Light_Bulb_1']['Power'] }}"
    command_topic: "cmnd/Zigbee/ZbSend"
    payload_on: '{"device":"Basement_Light_Bulb_1","send":{"Power":"On"} }' 
    payload_off: '{"device":"Basement_Light_Bulb_1","send":{"Power":"Off"} }'
    availability_topic: "tele/Zigbee/LWT"
    payload_available: "Online"
    payload_not_available: "Offline"
    optimistic: false
    qos: 0

And here is the message coming over via Zigbee2Tasmota:

tele/Zigbee/Basement_Light_Bulb_1/SENSOR: b'{"ZbReceived":{"Basement_Light_Bulb_1":{"Device":"0x8556","Name":"Basement_Light_Bulb_1","Power":"On","Endpoint":1,"LinkQuality":55}}}'

Any advice on how to troubleshoot? Is there a way to see what value Home Assistant is pulling?

I did some more digging and found a good rundown on how to set lights up: How to Use Zigbee2Tasmota with Home Assistant – The Helpful Idiot

I ended up making it a template like the examples on that page and it worked:

light:
  - platform: mqtt
    schema: template
    name: "Basement Light Bulb 1"
    state_topic: "tele/Zigbee/Basement_Light_Bulb_1/SENSOR"
    state_template: >
      {% if value_json['ZbReceived']['Basement_Light_Bulb_1']['Power'] == 0 %}
        off
      {% elif value_json['ZbReceived']['Basement_Light_Bulb_1']['Power'] == 1 %}
        on
      {% else  %}
        {{ states('light.basement_light_bulb_1') }}
      {% endif %}
    command_topic: "cmnd/Zigbee/ZbSend"
    command_on_template: >
      {"device": "Basement_Light_Bulb_1","send":{
      {%- if brightness is defined -%}
      "Dimmer": {%- if brightness == 255 -%}254{%- else -%}{{ brightness }}{%- endif -%}
      {%- else -%}
      "Power": 1
      {%- endif -%}
      }}
    command_off_template: '{"device": "Basement_Light_Bulb_1","send":{"Power":0}}'
    brightness_template: >
      {% if value_json['ZbReceived']['Basement_Light_Bulb_1']['Dimmer'] is defined %}
        {% if value_json['ZbReceived']['Basement_Light_Bulb_1']['Dimmer'] == 255 %}
          254
        {% else %}
          {{ value_json['ZbReceived']['Basement_Light_Bulb_1']['Dimmer'] }}
        {% endif %}
      {% else %}
        {{ state_attr('light.basement_light_bulb_1','brightness') }}
      {% endif %} 
    availability_topic: "tele/Zigbee/LWT"
    payload_available: "Online"
    payload_not_available: "Offline"
    optimistic: false
    qos: 0