Help needed with MQTT 2022.6 breaking change

As far as I can tell (and did myself), only the mqqt part needs to change.

The other (old) sensors need to remain under sensor:

For the new mqqt I used:

In your case something like:

mqtt:

#Shelly H&T sensor
  sensor:
   - name: "Temperatura Studio"
     state_topic: "shellies/SensoreHstudio/sensor/temperature"
     value_template: "{{ value }}"
     unit_of_measurement: "°C"
     icon: mdi:thermometer

sensor: #this was missing I think
#Dark Sky weater sensor     
  - platform: darksky
    api_key: !secret darksky_api
    language: it
    forecast:
      - 0
    hourly_forecast:
      - 0
      - 1
    monitored_conditions:
      - summary
      - icon
      - temperature
      - sunrise_time
      - sunset_time
      - alerts

  - platform: time_date
    display_options:
      - 'time'
      - 'date'   

  #System monitor sensor
  - platform: systemmonitor
    resources:
      - type: disk_use_percent
        arg: /
      - type: memory_free
      - type: processor_use
      - type: last_boot


#Life 360 sensor

  - platform: template
    sensors:
      andrea_phone:
        friendly_name: "Batteria Andrea"
        unit_of_measurement: '%'
        value_template: "{{ state_attr('device_tracker.life360_xxxxx_xxxxx', 'battery') }}"
        device_class: battery

Unless it’s a template sensor, of course.

Not sure what you mean. A template sensor can be under sensor: as well?

Or did you mean binary_sensor:?

Edit: sorry, I get what you mean:

template:
  sensor...

Template sensors should be moved to template:, having them under sensor: is no longer recommended.

Think I’m getting old here :-)… this is why homeassistant is still not for the bigger audience… too much nitty changes every update… the list of “breaking changes” is bigger than “new features” (joke).

4 Likes

Breaking Changes typically are new features. They’re listed separately because the change they introduce alters (breaks) the existing way of doing something. You are obliged to modify your existing configuration to conform with the changes.

In contrast, a non-Breaking Change is a new feature that doesn’t typically require modifying your existing configuration.

For more information about this particular Breaking Change:

Or they break the spirit of the user :roll_eyes:

2 Likes

If that’s all it takes to break their spirit then they should consider switching to another product or hobby.

thank you for your anser but this change doesn’t work . Maybe becouse I have a separate sensor.yaml
and sensor: !include sensor.yaml in configuration.yaml

Move the darksky sensor (and others) to sensor.yaml where all of your sensors are defined.

The only sensors that are defined separately are MQTT and Template (for modern style Template Sensors; legacy style continue to be defined under the sensor: domain).

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

mqtt: !include mqtt:yaml
template:  !include template:yaml

Please excuse me for this dumb question I am trying my best to understand this stuff but I have zero background in programming YAML

Yes, you can definitely do that.


EDIT

Correction. The file names should contain a period, not a colon.

mqtt: !include mqtt.yaml
template:  !include template.yaml

Thanks to petro for pointing out the typo.

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 :frowning:

1 Like

I want to cry :sob:

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).
template :
    sensors:
      my_wupws_humidity:
        unit_of_measurement: "%"
        value_template: "{{states('sensor.wupws_humidity') | int }}"

    sensors:
      andrea_phone:
        friendly_name: "Batteria Andrea"
        unit_of_measurement: '%'
        value_template: "{{ state_attr('device_tracker.life360_andrea_bb', 'battery') }}"
        device_class: battery
        

    sensors:
      elisa_phone:
        friendly_name: "Batteria Elisa"
        unit_of_measurement: '%'
        value_template: "{{ state_attr('device_tracker.life360_elisa_vv', 'battery') }}"
        device_class: battery
              

    sensors:
      neri_phone:
        friendly_name: "Batteria Neri"
        unit_of_measurement: '%'
        value_template: "{{ state_attr('device_tracker.life360_neri_me', 'battery') }}"
        device_class: battery              
   
    

    sensors:
      shelly_em_corrente_ch1:
        friendly_name: "Corrente casa"
        value_template: '{{ (states("sensor.Assorbimento_casa")|float / states("sensor.tensione_condominio")|float)|float|round(1) }}'
        unit_of_measurement: "Ampere"
        icon_template: mdi:current-ac
      shelly_em_corrente_ch2:
        friendly_name: "Corrente condominio"
        value_template: '{{ (states("sensor.Assorbimento_condominio")|float / states("sensor.tensione_condominio")|float)|float|round(1) }}'
        unit_of_measurement: "Ampere"
        icon_template: mdi:current-ac

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.

In addition, if you do this:

sensor: !include sensors.yaml
mqtt: !include mqtt.yaml
template:  !include template.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.

2 Likes

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

thank you

Op keeps adding : in his includes and you must have copied it. Op should make sure he specifies actual file names not template:yaml

2 Likes

Thank you guys for all your effort in helping me. really appreciated!

1 Like

Looks Like I’m need some help also moving to this new format. I have everything setup with my include to mqtt.yaml.

I tried to follow the example here, but I’m obviously missing something with the formatting.

You only need the first -sensor: . Remove the others.
Like:

  sensor:
    - name: "Teckin01 Energia Hoy"
      state_topic: "tele/teckin01/SENSOR"
      value_template: '{{ value_json["ENERGY"]["Today"] }}'
      unit_of_measurement: "kWh"
    - name: "Teckin01 Energia Ayer"
      state_topic: "tele/teckin01/SENSOR"
      value_template: '{{ value_json["ENERGY"]["Yesterday"] }}'
      unit_of_measurement: "kWh"
    - name: "Teckin01 Energia Total"
      state_topic: "tele/teckin01/SENSOR"
      value_template: '{{ value_json["ENERGY"]["Total"] }}'
      unit_of_measurement: "kWh"
1 Like