thank you for your answer.
So I should move all mqtt and template sensor in configuration yaml under
MQTT: and Template : is it correct?
Can I have on separate file using !include comand?
Something like
For template:, be aware that both the syntax and the functionality have changed with the new configuration format, it’s not just a matter of moving the sensor configurations over
Are you able to tell me if there is a source where I can understand how I have to change my sintax?
I made a template.yaml as follows and the configuration is valid but if I restart HA I receive an error. I am surely missing something. Is there an example I can follow?
Invalid config for [template]: [template] is an invalid option for [template]. Check: template->template. (See /config/template.yaml, line 1).
It’s in the documentation for the Template integration. However, you are not obligated to convert your existing Template Sensors, which are defined in what is now known as ‘legacy format’, into the new “modern format”. Just leave them in sensors.yaml.
then the first line in sensors.yaml should not contain sensor: key word (or mqtt: for mqtt.yaml or template: for templates.yaml). If you do include the key word on the first line, you are effectively duplicating it and it will fail Configuration Check.
EDIT
Correction. Replaced colon with period in file name.
thank you for your reply, I was just trying to update all the configurations while I was fixing the MQTT stuff.
Maybe I’ll try to update the “template question” in the future for now I fixed the MQTT config for the incoming 2022.9
OK, another one with problems converting to the new syntax.
My manual config is split across a number of “theme”-based yaml files in packages
Two of them have mqtt configured sensors. I am seeing the same problem in both. One will serve as an example.
I get no errors when I run ha core check, but when HA restarts I see errors of the form:
The version platform for the sensor integration does not support platform setup. Please remove it from your config.
17:05:59 – (ERROR) Sensor - message first occurred at 17:05:59 and shows up 2 times
Unable to prepare setup for platform mqtt.switch: Unable to set up component.
17:05:57 – (ERROR) setup.py
Setup failed for mqtt: Invalid config.
17:05:57 – (ERROR) setup.py
Invalid config for [mqtt]: [sensor] is an invalid option for [mqtt]. Check: mqtt->mqtt->sensor. (See ?, line ?). Please check the docs at https://www.home-assistant.io/integrations/mqtt
17:05:57 – (ERROR) config.py
and
2022-06-02 17:05:57 ERROR (MainThread) [homeassistant.config] Invalid config for [mqtt]: [sensor] is an invalid option for [mqtt]. Check: mqtt->mqtt->sensor. (See ?, line ?). Please check the docs at https://www.home-assistant.io/integrations/mqtt
2022-06-02 17:05:57 ERROR (MainThread) [homeassistant.setup] Setup failed for mqtt: Invalid config.
Thanks. I saw that, but I can’t see where that first mqtt: is.
The Mosquitto integration is configured through the GUI - there’s no reference to it in configuration.yaml. All the real config takes in places in packages. The relevant one starts:
# Batteries.yaml
# Stuff to report battery state and raise an elert of a battery state gets low.
#
# Customisations to facilitate selecting the filtered battery levels
homeassistant:
customize:
sensor.filtered_shed_battery:
type: "filtered"
sensor.filtered_bedroom1_battery:
type: "filtered"
sensor.filtered_bedroom2_battery:
type: "filtered"
sensor.filtered_livingroom_battery:
type: "filtered"
sensor.filtered_shack_battery:
type: "filtered"
# emonCMS battery sensors
mqtt:
sensor:
- name: "Shed Battery"
state_topic: "emon/emonth4/battery"
unit_of_measurement: "V"
device_class: battery
value_template: "{{ value | float | round(1) }}"
expire_after: 300
I see no place where an extra level got added in. However, I do see that VSC (I’m using the VSC editor addon) does put a blue hash highlight on that whole section.
Not sure about the terminology, but it looks like it’s not possible to have multiple instances of the mqtt: configuration key, each with a unique secondary identifier, the way you can with platform keys like binary_sensor, sensor, etc. This would be helpful (to me at least) to keep the YAML more manageable.
For example…
# this validates but has been deprecated
binary_sensor basement:
- platform: mqtt
name: Basement Motion 1
- platform: mqtt
name: Basement Motion 2
binary_sensor bedrooms:
- platform: mqtt
name: Hall Motion
# but this doesn't validate
mqtt basement:
binary_sensor:
- name: Basement Motion 1
- name: Basement Motion 2
mqtt bedrooms:
binary_sensor:
- name: Hall Motion
# and neither does this
mqtt:
binary_sensor basement:
- name: Basement Motion 1
- name: Basement Motion 2
binary_sensor bedrooms:
- name: Hall Motion
I have rewritten syntax in accordance to recent changes, but now when I check config before rebooting HA I get:
Invalid config for [mqtt]: [entity_id] is an invalid option for [mqtt]. Check: mqtt->mqtt->sensor->44->entity_id. (See /config/configuration.yaml, line 81).
Here’s the look of My config.yaml, line 81 corresponds to MQTT: