'dict object' has no attribute 'Occupancy' when rendering

You’re welcome!

Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions.

For more information about the Solution tag, refer to guideline 21 in the FAQ.


I need to see an example of the payload sent when occupancy is reported in order to confirm the values provided for the “Occupancy” key. The following example, for an MQTT Binary Sensor, assumes the values are numeric 1 and 0.

    - name: "PIR Vallhorn Landing"
      unique_id: pir_vallhorn_landing_2024_07_27
      state_topic: "tele/zigbee-bridge/vallhorn-landing/SENSOR"
      device_class: occupancy
      value_template: >
          {{ value_json['ZbReceived']['0x4D91']['Occupancy']
            if value_json['ZbReceived']['0x4D91']['Occupancy'] is defined
            else this.state | default(0, true) }}
      payload_off: 0
      payload_on: 1

If the values are not numeric 1 and 0 or are strings, then the template will need modifications.