"The 'value_template' option has been removed" errors

“The ‘value_template’ option has been removed” errors

Hi, I am getting constant error messages in HA logs.

Devices becomes unavailable in HA but everything works in zigbee2mqtt itself.

All zigbee devices in HA are discovered automatically. I had no reason to modify configuration or something in config.
There are no “value_template” in any config related to mqtt or zigbee configuration
First failed device config seems looks good in zigbee2mqtt devices.yaml

'0x54ef4410002460aa':
  friendly_name: BathRoomLight
  homeassistant:
    switch:
      type: light
      object_id: light
    switch_left:
      type: light
      object_id: light_left
    switch_right:
      type: light
      object_id: light_right
    light:
      state_value_template: '{{ value_json.state }}'
    light_left:
      state_value_template: '{{ value_json.state_left }}'
    light_right:
      state_value_template: '{{ value_json.state_right }}'
  optimistic: true
  retain: true

Once I fixed by hand using MQTT explorer by replacing value_template to state_value_template in homeassistant/light/{device}/config topic
But after some restarts devices again started become unavailable. And NOT all together at once, but after each HA restart I see more and more devices unavailable. And “value_template” again apears in those light topics somehow.
I suspecting that somehow mqtt (local HA mosquito addon) is messing with me and reposting some old retained messages. I am not sure what to blame and how to find root couse.
Can anyone help to solve this mystery?

Home Assistant 2023.1.6
Supervisor 2022.12.1
Operating System 9.4
Frontend 20230110.0
HA is running in Qnap NAS VM
Moquito and Z2M addons are Latest. Currently no updates available to those.

There is my zigbee2mqtt configuration.yaml. This is auto generated by front configuration (I did not modified this myself)

external_converters: []
devices:
  - devices.yaml
groups:
  - groups.yaml
homeassistant:
  legacy_entity_attributes: true
  legacy_triggers: true
  discovery_topic: homeassistant
permit_join: false
mqtt:
  base_topic: zigbee2mqtt
  user: addons
  password: {REDACTED}
  server: mqtt://core-mosquitto:1883
serial:
  port: >-
    /dev/serial/by-id/usb-dresden_elektronik_ingenieurtechnik_GmbH_ConBee_II_DE2465463-if00
  adapter: deconz
advanced:
  log_level: debug
  pan_id: 6754
  channel: 11
  network_key: {REDACTED}

  availability_blocklist: []
  availability_passlist: []
device_options: {}
blocklist: []
passlist: []
queue: {}
frontend:
  port: 8099
experimental: {}
availability: true

and mqtt has single manual device in HA configuration.yaml no additional mqtt configuration exists in HA configuration folder. Mosquito is setup from GUI

mqtt:
  binary_sensor:
    name: "NFC"
    state_topic: "nfc/alive"
    payload_on: "ON"
    payload_off: "OFF"
    expire_after: 120

This is very likely coming from retained discovery messages in your mqtt broker. Delete them.

What version is ‘latest’ ? Could be you still use the deprecated repository. Anyway, today is the 1st, a new version will be released today.

[versions]
zigbee2mqtt 1.29.2-1
mosquito 6.1.3

I was changing those retained messages and removed value_template and it works for some time. but again apears

I removed all retained messages that has “value_template”. Updated HA and z2m today to latest versions, rebooted VM where HA mqtt and z2m is running. And again mqtt was flooded with the same messages. I dont know, the last option I see is to install new separate mqtt server and redirect to it, witch I dont want to do becouse to much work reconfigure everyting. Any more suggestions?

Update: I found how to fix it myself.

  1. on light devices in devices.yaml as old one visible in previous post I added value_template: null and dicovery payload become as expected (without value_template)
light_right:
      value_template: null
      state_value_template: '{{ value_json.state_right }}'

strange that z2m cannot update devices itself and fix it, when it is known that it breaks HA and remove this frustration from user. I expected that updating z2m would fix it. so maybe its “by design” or somehow failed to update properly

  1. was issue that those lights somehow got new ids in HA and I missed that thinking that it is not discovered due to discovery errors. There I have no explanation and whos foult it is.

for example : light.office_light changed to light.officelight

But now everything managed. just only 2 days of pain!