MQTT Error after Update to 2022.2

I am getting this MQTT error ever since updating to 2022.2. These are not new lights, they have been working fine. These are also not the only lights I have in MQTT, but these are the only ones not working.

Exception in async_discover when dispatching 'mqtt_discovery_new_light_mqtt': ({'name': 'Bar1', 'state_topic': 'tele/tasmota_3A7834/STATE', 'availability_topic': 'tele/tasmota_3A7834/LWT', 'payload_available': 'Online', 'payload_not_available': 'Offline', 'command_topic': 'cmnd/tasmota_3A7834/POWER', 'value_template': '{{value_json.POWER}}', 'payload_off': 'OFF', 'payload_on': 'ON', 'unique_id': '3A7834_LI_1', 'device': {'identifiers': ['3A7834']}, 'brightness_command_topic': 'cmnd/tasmota_3A7834/Dimmer', 'brightness_state_topic': 'tele/tasmota_3A7834/STATE', 'brightness_scale': 100, 'on_command_type': 'brightness', 'brightness_value_template': '{{value_json.Dimmer}}', 'rgb_command_topic': 'cmnd/tasmota_3A7834/Color2', 'rgb_state_topic': 'tele/tasmota_3A7834/STATE', 'rgb_value_template': "{{value_json.Color.split(',')[0:3]|join(',')}}", 'effect_command_topic': 'cmnd/tasmota_3A7834/Scheme', 'effect_state_topic': 'tele/tasmota_3A7834/STATE', 'effect_value_template': '{{value_json.Scheme}}', 'effect_list': ['0', '1', '2', '3', '4'], 'color_temp_command_topic': 'cmnd/tasmota_3A7834/CT', 'color_temp_state_topic': 'tele/tasmota_3A7834/STATE', 'color_temp_value_template': '{{value_json.CT}}', 'white_value_command_topic': 'cmnd/tasmota_3A7834/White', 'white_value_state_topic': 'tele/tasmota_3A7834/STATE', 'white_value_scale': 100, 'white_value_template': '{{value_json.White}}', 'platform': 'mqtt'},) Traceback (most recent call last): File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 272, in __call__ return self._compiled([], data) File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 817, in validate_callable return schema(data) File "/usr/src/homeassistant/homeassistant/helpers/config_validation.py", line 813, in validator raise vol.Invalid(warning % arguments) voluptuous.error.Invalid: The 'value_template' option has been removed, please remove it from your configuration During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/mqtt/mixins.py", line 211, in async_discover config = schema(discovery_payload) File "/usr/local/lib/python3.9/site-packages/voluptuous/validators.py", line 218, in __call__ return self._exec((Schema(val) for val in self.validators), v) File "/usr/local/lib/python3.9/site-packages/voluptuous/validators.py", line 341, in _exec raise e if self.msg is None else AllInvalid(self.msg, path=path) File "/usr/local/lib/python3.9/site-packages/voluptuous/validators.py", line 337, in _exec v = func(v) File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 272, in __call__ return self._compiled([], data) File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 817, in validate_callable return schema(data) File "/usr/src/homeassistant/homeassistant/components/mqtt/light/__init__.py", line 41, in validate_mqtt_light_discovery return schemas[value[CONF_SCHEMA]](value) File "/usr/local/lib/python3.9/site-packages/voluptuous/validators.py", line 218, in __call__ return self._exec((Schema(val) for val in self.validators), v) File "/usr/local/lib/python3.9/site-packages/voluptuous/validators.py", line 341, in _exec raise e if self.msg is None else AllInvalid(self.msg, path=path) File "/usr/local/lib/python3.9/site-packages/voluptuous/validators.py", line 337, in _exec v = func(v) File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 276, in __call__ raise er.MultipleInvalid([e]) voluptuous.error.MultipleInvalid: The 'value_template' option has been removed, please remove it from your configuration

The last line explains the problem.

The use of value_template in Home Assistantā€™s MQTT Discovery was deprecated in the 2021.7 release.

As of release 2022.2, the presence of value_template is rejected:

The lights that you have flashed with Tasmota are using Home Assistantā€™s MQTT Discovery method but are employing the now invalid value_template option.

I suggest you consider modifying Tasmotaā€™s configuration for each of your lights to use Tasmotaā€™s native discovery method ( SetOption19 0). It means you will also need to use the Tasmota integration) as opposed to using Home Assistantā€™s MQTT Discovery method which Tasmota has ceased to support.

I have the tasmota integration installed and ran setoption 0 on each of the bulbs, but the devices still show unavailable in HA. Using TasmoAdmin, I can control each bulb just fine.

Iā€™m seeing the same thing. I donā€™t have any config for the light in question, as it was added to MQTT via the UI, using MQTT auto-discovery. Yet I see this error in my config. Iā€™ve done a full-text search and nothing matches the template_value lines as mentioned above in my entire config directory.

So Iā€™m thinking this code is cached inside the UI-generated MQTT config hidden in HA.

What is the fix? Should I remove the devices from MQTT and hope they show up again?

EDIT: Removing the device did not fix it for me. I could not get it to reappear in HA. I ended up migrating my lights to the Tasmota integration, which resolved the errors.

You want to use SetOption19 0 in the console for the device (note 19 on end). After that check the Integrations page and look at the Tasmota integration to see if it lists 1 or more devices. Note you need a relatively recent version of Tasmota for this to work (9.1+ from memory).

Because itā€™s not stored there. Itā€™s on the broker.

They certainly will, given that you switched from Home Assistantā€™s MQTT Discovery to Tasmotaā€™s discovery method. In the Devices view, look for the ones indicating Tasmota in the Integration column.

Thatā€™s good but itā€™s completely separate functionality from the discovery process.

Agreed; thatā€™s what I have suggested that ofcdduke do to correct the problem. Thereā€™s another way to fix it and thatā€™s by overwriting each deviceā€™s discovery payload with a revised version (that replaces value_template with state_value_template). However, for the long-term, itā€™s best to switch to Tasmotaā€™s discovery method.

I switched to the Tasmota discovery, but I was still not seeing the devices in the Tasmota integration. Then I saw your post about updating the Tasmota firmware. I updated to the latest fw and like magic, everything now works like it should. Thanks again for all the help!

Itā€™s also mentioned in the documentation link I provided you in my first post. Itā€™s the third bullet point in the Requirements section:

Tasmota devices flashed with version 9.2, or later (tasmota-lite.bin does not support this integration).

value_template 

is depreciated! instead you need to use

state_value_template

hope this helps :slight_smile:

1 Like

Taras, thankyou for your instructions here, I had realised that MQTT was the problem, but had no idea how to fix it or what to change. With your instruction managed to have it back up and running in only a minute. (If Iā€™d only found this thread 60 minutes ago!) cheers

Evening all, I have an issue where since the update none of my door sensors are reading. The are rf sensors and I an using a Tasmota flashed rf bridge running the latest version of Tasmota.

I have the intergation in home assistant and it finds the bridge but how do I get the information from the bridge to home assistant.?

In my HA config file I have tried to change value_template to state_value_template but it thows up an error stating it is in valid for a binary sensor.

    - platform: mqtt
      state_topic: "tele/rf-bridge/RESULT"
      name: 'Front Door'
      state_value_template: '{{value_json.RfReceived.Data}}'
      payload_on: "8E470A"
      payload_off: "8E470E"
      device_class: door
      qos: 1

Any help would be greatly received.

1 Like

Using Home Assistant 2022.2.9 now.

I had all the tasmota devices (smart plugs and smart lights) configed with ā€œsetoption19 1ā€ long time ago. I did noticed that I had this MQTT error as well but all tasmota devices worked fine so I didnā€™t pay attention to it.

After checking the log carefully today I found that those errors are from tasmota devices that currently powered off and not in use. All other tasmota devices in use are worked ok.

Devices are already on 9.2+. Are these the proper steps for upgrading? 1) add tasmota integration, 2) on device console, setoption19 0.

Or since they worked ok just donā€™t do anything?

I need to solve this exact same problem and have not been able to find a method to parse MQTT returned values to extract the RFBridge payload. If anyone can point us to an appropriate method for this, it would be appreciated.

I second that, I saw other people mentioning to make an automation to trigger a mqtt publish message via script+automationā€¦but that does not seem to work for me, anyone else tried something similar with better results?

The script to fix my tasmota 6.6 lights :

  scripttasmotalights:
    sequence:
#      - service: mqtt.publish
#        data:
#          retain: true
#          topic: 
#          payload: 
      - service: mqtt.publish
        data:
          retain: true
          topic: homeassistant/light/689626_LI_1/config
          payload: '{"name":"lichtbovenkleineslaapkamer","cmd_t":"~cmnd/POWER","stat_t":"~tele/STATE","stat_val_tpl":"{% raw %}{{value_json.POWER}}{% endraw %}","pl_off":"OFF","pl_on":"ON","avty_t":"~tele/LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"689626_LI_1","device":{"identifiers":["689626"]},"~":"lichtbovenkleineslaapkamer/"}'      
      - service: mqtt.publish
        data:
          retain: true
          topic: homeassistant/light/C7D5C9_LI_1/config
          payload: '{"name":"lichtbadkamer","cmd_t":"~cmnd/POWER","stat_t":"~tele/STATE","stat_val_tpl":"{% raw %}{{value_json.POWER}}{% endraw %}","pl_off":"OFF","pl_on":"ON","avty_t":"~tele/LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"C7D5C9_LI_1","device":{"identifiers":["C7D5C9"]},"~":"lichtbadkamer/"}'
      - service: mqtt.publish
        data:
          retain: true
          topic: homeassistant/light/688F47_LI_1/config
          payload: '{"name":"lichtbovenoudeslaapkamer ","cmd_t":"~cmnd/POWER","stat_t":"~tele/STATE","stat_val_tpl":"{% raw %}{{value_json.POWER}}{% endraw %}","pl_off":"OFF","pl_on":"ON","avty_t":"~tele/LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"688F47_LI_1","device":{"identifiers":["688F47"]},"~":"lichtbovenoudeslaapkamer/"}'
      - service: mqtt.publish
        data:
          retain: true
          topic: homeassistant/light/68ADCE_LI_1/config
          payload: '{"name":"lichtbovengang","cmd_t":"~cmnd/POWER","stat_t":"~tele/STATE","stat_val_tpl":"{% raw %}{{value_json.POWER}}{% endraw %}","pl_off":"OFF","pl_on":"ON","avty_t":"~tele/LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"68ADCE_LI_1","device":{"identifiers":["68ADCE"]},"~":"lichtbovengang/"}'
      - service: mqtt.publish
        data:
          retain: true
          topic: homeassistant/light/68A930_LI_1/config
          payload: '{"name":"lichtzitkamerruit","cmd_t":"~cmnd/POWER","stat_t":"~tele/STATE","stat_val_tpl":"{% raw %}{{value_json.POWER}}{% endraw %}","pl_off":"OFF","pl_on":"ON","avty_t":"~tele/LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"68A930_LI_1","device":{"identifiers":["68A930"]},"~":"lichtzitkamerruit/"}'
      - service: mqtt.publish
        data:
          retain: true
          topic: homeassistant/light/D933EC_LI_1/config
          payload: '{"name":"lichtboventrapgat","cmd_t":"~cmnd/POWER","stat_t":"~tele/STATE","stat_val_tpl":"{% raw %}{{value_json.POWER}}{% endraw %}","pl_off":"OFF","pl_on":"ON","avty_t":"~tele/LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"D933EC_LI_1","device":{"identifiers":["D933EC"],"connections":[["mac","60:01:94:D9:33:EC"]]},"~":"lichtboventrapgat/"}'
      - service: mqtt.publish
        data:
          retain: true
          topic: homeassistant/light/B33669_LI_1/config
          payload: '{"name":"lichtvooraangrotelichten","cmd_t":"~cmnd/POWER","stat_t":"~tele/STATE","stat_val_tpl":"{% raw %}{{value_json.POWER}}{% endraw %}","pl_off":"OFF","pl_on":"ON","avty_t":"~tele/LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"B33669_LI_1","device":{"identifiers":["B33669"]},"~":"lichtvooraangrotelichten/"}'
      - service: mqtt.publish
        data:
          retain: true
          topic: homeassistant/light/B391BE_LI_1/config
          payload: '{"name":"lichtvooraankleinelichten","cmd_t":"~cmnd/POWER","stat_t":"~tele/STATE","stat_val_tpl":"{% raw %}{{value_json.POWER}}{% endraw %}","pl_off":"OFF","pl_on":"ON","avty_t":"~tele/LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"B391BE_LI_1","device":{"identifiers":["B391BE"]},"~":"lichtvooraankleinelichten/"}'
      - service: mqtt.publish
        data:
          retain: true
          topic: homeassistant/light/B36127_LI_1/config
          payload: '{"name":"lichtvooraandeur","cmd_t":"~cmnd/POWER","stat_t":"~tele/STATE","stat_val_tpl":"{% raw %}{{value_json.POWER}}{% endraw %}","pl_off":"OFF","pl_on":"ON","avty_t":"~tele/LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"B36127_LI_1","device":{"identifiers":["B36127"]},"~":"lichtvooraandeur/"}'
      - service: mqtt.publish
        data:
          retain: true
          topic: homeassistant/light/68BD1D_LI_1/config
          payload: '{"name":"lichtzitkamermuur","cmd_t":"~cmnd/POWER","stat_t":"~tele/STATE","stat_val_tpl":"{% raw %}{{value_json.POWER}}{% endraw %}","pl_off":"OFF","pl_on":"ON","avty_t":"~tele/LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"68BD1D_LI_1","device":{"identifiers":["68BD1D"]},"~":"lichtzitkamermuur/"}'
      - service: mqtt.publish
        data:
          retain: true
          topic: homeassistant/light/AB019C_LI_1/config
          payload: '{"name":"lichtbovenschuindak","cmd_t":"~cmnd/POWER","stat_t":"~tele/STATE","stat_val_tpl":"{% raw %}{{value_json.POWER}}{% endraw %}","pl_off":"OFF","pl_on":"ON","avty_t":"~tele/LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"AB019C_LI_1","device":{"identifiers":["AB019C"]},"~":"lichtbovenschuindak/"}'
      - service: mqtt.publish
        data:
          retain: true
          topic: homeassistant/light/68BF3C_LI_1/config
          payload: '{"name":"lichtkeuken","cmd_t":"~cmnd/POWER","stat_t":"~tele/STATE","stat_val_tpl":"{% raw %}{{value_json.POWER}}{% endraw %}","pl_off":"OFF","pl_on":"ON","avty_t":"~tele/LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"68BF3C_LI_1","device":{"identifiers":["68BF3C"]},"~":"lichtkeuken/"}'
      - service: mqtt.publish
        data:
          retain: true
          topic: homeassistant/light/BA335F_LI_1/config
          payload: '{"name":"lichtbovenoverloop","cmd_t":"~cmnd/POWER","stat_t":"~tele/STATE","stat_val_tpl":"{% raw %}{{value_json.POWER}}{% endraw %}","pl_off":"OFF","pl_on":"ON","avty_t":"~tele/LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"BA335F_LI_1","device":{"identifiers":["BA335F"]},"~":"lichtbovenoverloop/"}'
      - service: mqtt.publish
        data:
          retain: true
          topic: homeassistant/light/A9BBEF_LI_1/config
          payload: '{"name":"lichtbuitenvoordeur","cmd_t":"~cmnd/POWER","stat_t":"~tele/STATE","stat_val_tpl":"{% raw %}{{value_json.POWER}}{% endraw %}","pl_off":"OFF","pl_on":"ON","avty_t":"~tele/LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"A9BBEF_LI_1","device":{"identifiers":["A9BBEF"]},"~":"lichtbuitenvoordeur/"}'
      - service: mqtt.publish
        data:
          retain: true
          topic: homeassistant/light/68AF8A_LI_1/config
          payload: '{"name":"lichteetkamer","cmd_t":"~cmnd/POWER","stat_t":"~tele/STATE","stat_val_tpl":"{% raw %}{{value_json.POWER}}{% endraw %}","pl_off":"OFF","pl_on":"ON","avty_t":"~tele/LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"68AF8A_LI_1","device":{"identifiers":["68AF8A"]},"~":"lichteetkamer/"}'
      - service: mqtt.publish
        data:
          retain: true
          topic: homeassistant/light/AA8028_LI_1/config
          payload: '{"name":"lichtwaskot","cmd_t":"~cmnd/POWER","stat_t":"~tele/STATE","stat_val_tpl":"{% raw %}{{value_json.POWER}}{% endraw %}","pl_off":"OFF","pl_on":"ON","avty_t":"~tele/LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"AA8028_LI_1","device":{"identifiers":["AA8028"]},"~":"lichtwaskot/"}'
      - service: mqtt.publish
        data:
          retain: true
          topic: homeassistant/light/B335B0_LI_1/config
          payload: '{"name":"lichtslaapkamervooraan","cmd_t":"~cmnd/POWER","stat_t":"~tele/STATE","stat_val_tpl":"{% raw %}{{value_json.POWER}}{% endraw %}","pl_off":"OFF","pl_on":"ON","avty_t":"~tele/LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"B335B0_LI_1","device":{"identifiers":["B335B0"]},"~":"lichtslaapkamervooraan/"}'
      - service: mqtt.publish
        data:
          retain: true
          topic: homeassistant/light/AA4432_LI_1/config
          payload: '{"name":"lichtslaapkamervooraan2","cmd_t":"~cmnd/POWER","stat_t":"~tele/STATE","stat_val_tpl":"{% raw %}{{value_json.POWER}}{% endraw %}","pl_off":"OFF","pl_on":"ON","avty_t":"~tele/LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"AA4432_LI_1","device":{"identifiers":["AA4432"]},"~":"lichtslaapkamervooraan2/"}'
      - service: mqtt.publish
        data:
          retain: true
          topic: homeassistant/light/D933EC_LI_1/config
          payload: '{"name":"lichtboventrapgat","cmd_t":"~cmnd/POWER","stat_t":"~tele/STATE","stat_val_tpl":"{% raw %}{{value_json.POWER}}{% endraw %}","pl_off":"OFF","pl_on":"ON","avty_t":"~tele/LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"D933EC_LI_1","device":{"identifiers":["D933EC"],"connections":[["mac","60:01:94:D9:33:EC"]]},"~":"lichtboventrapgat/"}'
      - service: mqtt.publish
        data:
          retain: true
          topic: homeassistant/light/B391BE_LI_1/config
          payload: '{"name":"lichtvooraankleinelichten","cmd_t":"~cmnd/POWER","stat_t":"~tele/STATE","stat_val_tpl":"{% raw %}{{value_json.POWER}}{% endraw %}","pl_off":"OFF","pl_on":"ON","avty_t":"~tele/LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"B391BE_LI_1","device":{"identifiers":["B391BE"]},"~":"lichtvooraankleinelichten/"}'
      - service: mqtt.publish
        data:
          retain: true
          topic: homeassistant/light/B33669_LI_1/config
          payload: '{"name":"lichtvooraangrotelichten","cmd_t":"~cmnd/POWER","stat_t":"~tele/STATE","stat_val_tpl":"{% raw %}{{value_json.POWER}}{% endraw %}","pl_off":"OFF","pl_on":"ON","avty_t":"~tele/LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"B33669_LI_1","device":{"identifiers":["B33669"]},"~":"lichtvooraangrotelichten/"}'
      - service: mqtt.publish
        data:
          retain: true
          topic: homeassistant/light/AA4432_LI_1/config
          payload: '{"name":"lichtslaapkamervooraan2","cmd_t":"~cmnd/POWER","stat_t":"~tele/STATE","stat_val_tpl":"{% raw %}{{value_json.POWER}}{% endraw %}","pl_off":"OFF","pl_on":"ON","avty_t":"~tele/LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"AA4432_LI_1","device":{"identifiers":["AA4432"]},"~":"lichtslaapkamervooraan2/"}'

1 Like

thanks for that script. With it managed to get my lights back up for now after tearing most of my hair out.
But is this going to work long term? All of my tasmotas are set up with SetOption19 1.
Or do I have to upgrade all of them eventually?