Does `clear` in `value_json` have some special meaning?

My homemade alarm system sends out a JSON object on MQTT, and one value in this object is clear. But if I define a sensor with:

value_template: '{{ value_json.clear }}'

No value is received, however the examples below works just fine:

value_template: '{{ value_json.fault }}'
value_template: '{{ value_json.tamper }}'

It also works if I change the clear value to something else, like clear_to_arm.

Does value_json.clear have some kind of special meaning?

Here is the full JSON object sent by the security system:

{
    "attempts": 0,
    "battery_v": 0.0,
    "clear": true,
    "clear_to_arm": true,
    "fault": false,
    "state": "disarmed",
    "status": {
        "cabinet_temp": true,
        "code_attempts": true,
        "ext_tamper_ok": true,
        "healthchecks_ok": true,
        "mains_power_ok": true,
        "mqtt_connected": true,
        "panel_tamper_ok": true,
        "sensor_door1_battery": true,
        "sensor_door2_battery": true,
        "sensor_door3_battery": true,
        "sensor_motion2_alive": true,
        "sensor_panel_tamper_alive": true,
        "sensor_panel_tamper_battery": true,
        "sensor_water_leak1_alive": true,
        "sensor_water_leak1_battery": true,
        "siren1_not_blocked": true,
        "siren1_output_ok": true,
        "siren2_not_blocked": true,
        "siren2_output_ok": true,
        "zigbee_bridge": true,
        "zwave_bridge": true
    },
    "tamper": false,
    "temperature": 21.5,
    "triggered": {
        "timestamp": null,
        "zone": null
    },
    "zones": {
        "door1": false,
        "door2": false,
        "door3": false,
        "emergency": false,
        "ext_tamper": false,
        "motion2": false,
        "panel_tamper": false,
        "panic": false,
        "water_leak1": false,
        "zone01": false
    }
}

It Does, it empties the dictionary. Access it with brackets instead. value_json['clear']

That makes sense, thanks. This seems to be undocumented, or at least I couldn’t find it anywhere. Maybe a tiny note on Templating - Home Assistant would be in order?

It would be impossible to document all these things. The rule of thumb is that you can’t override methods on an object. Clear is a method on a dictionary so it falls into that category.

That was the missing piece of the puzzle for my part, then it makes perfect sense of course :slight_smile:

Leaving this here for future reference: Python Dictionary Methods

Thanks again.

Value_json can come through as any python type, so you’d have to link to lists, bools, strings, floats, ordereddicts, etc… that’s why it’s out of scope for the docs.

Right — of course, depending on the JSON payload. Thanks for the thorough explanation. :vulcan_salute: