MQTT Configuration Bug?-- Constant Spinning circle when trying to Validate--- I have attached the section of my configuration causing the issue

Hello all,

Can someone help me determine if there is a current bug with regards to the mqtt configuration setup? Below is the section of my configuration that causes the configuration validator to spin constantly and never complete when I comment out the “OLD” section and try to use the uncommented “NEW” section. If I leave the “OLD” area uncommented (while also commenting out the “NEW” area) and validate, the validation completes successfully.

I have had this problem since the original announcement of the changeover to the new code styling of the mqtt sensor. And was hoping this issue might have been a bug and had been fixed in one of the subsequent HA versions but whatever is going on seems to still be an issue.-- Maybe something in my new code is not right but I’m pretty sure I matched it identically from old to new unless I’m missing something completely??

Thank you all for any insights/ help you can provide. I can post a video of this behavior and link to it if necessary.

#####NEW######

# mqtt:
#   sensor:
#     - name: "Washer Status"
#       state_topic: "house/washer/status"
#     - name: "Washer Last Complete"
#       state_topic: "house/washer/time_complete"
#       device_class: timestamp
#     - name: "Washer Last Emptied"
#       state_topic: "house/washer/time_emptied"
#       device_class: timestamp

#####/NEW######

#####/OLD######

sensor:
  - platform: "mqtt"
    name: "Washer Status"
    state_topic: "house/washer/status"
  - platform: "mqtt"
    name: "Washer Last Complete"
    state_topic: "house/washer/time_complete"
    device_class: timestamp
  - platform: "mqtt"
    name: "Washer Last Emptied"
    state_topic: "house/washer/time_emptied"
    device_class: timestamp

#####/OLD######

Where do you have that code above located? is it in configuration.yaml directly or is it in an !include/package?

I think you may be on to something. I have that in a package.

Is that a “no go”?

Oh sure you can put them in a package with no issues. I have several that are in packages.

I was just trying to eliminate possibilities before calling it a bug.

I just copy/pasted your “new” code into my HA in a package and the config check is valid.

What version of HA are you on?

I tested it on 2022.9.2

Thank you for testing that for me on your system.

This is strange. I am on the latest which I believe is 2022.9.6.

This has been the same for me since 2022.7 so I don’t know what’s going on.

It only starts doing the no validation when changing this section of my config involving the Mqtt sensor breaking change.

I’m at a loss on this one.

I may post a link to a video of the behavior here when I get back to my machine.

Maybe you should post more code before and after that section. There might be something going on there.

Ahh, that’s possible.

I’ll post that whole file first.

When getting the constant spinning, I am pretty much just commenting out the “old” and uncommenting the “new” but maybe there is something else I’m not catching

Here was that whole file:

Thank you for helping me with this @finity

input_boolean:
  washer_finished:
    name: Washer Finished
    icon: mdi:washing-machine
input_number:
  stepper_control_right_test_blind:
    name: Stepper Control Right Test Blind
    min: -200
    max: 460
    step: 1
    mode: slider
  stepper_control_left_test_blind:
    name: Stepper Control Left Test Blind
    min: -200
    max: 700
    step: 1
    mode: slider

#####NEW######

# mqtt:
#   sensor:
#     - name: "Washer Status"
#       state_topic: "house/washer/status"
#     - name: "Washer Last Complete"
#       state_topic: "house/washer/time_complete"
#       device_class: timestamp
#     - name: "Washer Last Emptied"
#       state_topic: "house/washer/time_emptied"
#       device_class: timestamp

#   # # MQTT Sensor for DishWasher Status.
#   # - platform: mqtt
#   #   name: "DishWasher Status"
#   #   state_topic: "house/dishwasher/status"
#   # MQTT Sensor for Washing Machine Status.

#####/NEW######

#####/OLD######

sensor:
  - platform: "mqtt"
    name: "Washer Status"
    state_topic: "house/washer/status"
  - platform: "mqtt"
    name: "Washer Last Complete"
    state_topic: "house/washer/time_complete"
    device_class: timestamp
  - platform: "mqtt"
    name: "Washer Last Emptied"
    state_topic: "house/washer/time_emptied"
    device_class: timestamp

#####/OLD######

  # - platform: mqtt_room
  #   device_id: 123testid
  #   state_topic: "espresense/rooms"

# One entry for each beacon you want to track
  - platform: mqtt_room
    device_id: "apple:1006:10-8"
    name: 'Westons iPhone Room Presence'
    state_topic: 'espresense/devices/apple:1006:10-8'
    timeout: 10
    away_timeout: 120

utility_meter:
  washer_daily_kwh:
    source: sensor.washer_switch_electric_consumed_kwh
    cycle: daily
  washer_weekly_kwh:
    source: sensor.washer_switch_electric_consumed_kwh
    cycle: weekly

automation:
  - id: washer_running
    alias: Washer Running
    trigger:
      - above: 4
        entity_id: sensor.washer_power_consumed_w
        platform: numeric_state
    condition:
      condition: or
      conditions:
        - condition: state
          entity_id: sensor.washer_status
          state: idle
        - condition: state
          entity_id: sensor.washer_status
          state: complete
    action:
      - service: mqtt.publish
        data:
          topic: house/washer/status
          payload: running
          retain: true
    initial_state: true

  - id: washer_complete
    alias: Washer Complete
    trigger:
      - below: 2
        entity_id: sensor.washer_power_consumed_w
        platform: numeric_state
    condition:
      - condition: state
        entity_id: sensor.washer_status
        state: running
    action:
      - service: mqtt.publish
        data:
          topic: house/washer/status
          payload: complete
          retain: true
      - service: mqtt.publish
        data:
          topic: house/washer/time_complete
          payload: "{{ utcnow().isoformat() }}"
          # payload: '{{ now().timestamp() }}'
          retain: true
    initial_state: true

  - id: washer_notification
    initial_state: true
    alias: Washer Notification
    trigger:
      - platform: state
        entity_id: sensor.washer_status
        from: running
        to: complete
    action:
      - service: script.speech_engine
        data:
          # who: 'kitchen'
          message: "Just a quick heads up, It appears the washing machine has completed its cycle"
      - service: script.text_notify
        data:
          who: parents
          title: Washing Machine Finished
          message: "Just a quick heads up, It appears the washing machine has completed its cycle"
          data:
          group: "appliances"
          tag:
      - service: script.turn_on
        entity_id: script.washer_finished_notification_audible
      - service: input_boolean.turn_on
        data: {}
        target:
          entity_id: input_boolean.washer_finished

  - id: washer_emptied
    initial_state: true
    alias: Washer Emptied
    trigger:
      - platform: state
        entity_id: binary_sensor.washer_door
        from: "off"
        to: "on"
    action:
      - service: mqtt.publish
        data:
          topic: house/washer/status
          payload: idle
          retain: true
      - service: script.turn_off
        entity_id: script.washer_finished_notification_audible
      - service: mqtt.publish
        data:
          topic: house/washer/time_emptied
          # payload: '{{ now().timestamp() }}'
          payload: "{{ utcnow().isoformat() }}"
          retain: true
      - service: input_boolean.turn_off
        data: {}
        target:
          entity_id: input_boolean.washer_finished

script:
  washer_finished_notification_audible:
    sequence:
      - repeat:
          while:
            - condition: state
              entity_id: sensor.washer_status
              state: "complete"
          sequence:
            - delay:
                minutes: 30
            - service: script.simplified_washer_audible

  simplified_washer_audible:
    sequence:
      - condition: state
        entity_id: group.family
        state: "home"
      - condition: state
        entity_id: sensor.washer_status
        state: complete
      - service: script.speech_engine
        data:
          # who: 'kitchen'
          message: >
            {{ [
              'Pardon me, ',
              'Excuse me, ',
              'I do not mean to interrupt, but,',
              'I hate to interrupt, but,',
              'I beg your pardon, ',
              'I do not mean to intrude, but, ',
              'I am sorry to interrupt, but. ',
              'Just a quick heads up, '
              ] | random }}
            <p>
              The washing machine completed its cycle 
              {% set seconds = now().timestamp() - as_timestamp(states.sensor.washer_status.last_changed) %}
              {% if (seconds / ( 60 * 60 )) | int == 1 %}
                over an hour ago.
                {{ [
                'Do not forget to rotate the clothes.', 
                'Was someone going to rotate the laundry?',
                'Once you rotate the laundry I will stop reminding you to do it. So if you want me to stop. Its up to you.'
                ] | random }}
              {% elif (seconds / ( 60 * 60 )) | int > 1 and (seconds / ( 60 * 60 )) | int < 6 %}
                over {{ (seconds //  ( 60 * 60 )) | int }} hours ago.
                {{ [
                'Much longer and you are going to need to wash them again.', 
                'Someone needs to rotate the laundry.',
                'Do not forget about the clothes in the washing machine.',
                'Surely you did not mean to forget about the clothes. Mistakes happen. But you can still fix it.',
                'Do you like your clothes smelling like mildew? Becasue that is what is happening right now.'
                ] | random }}
              {% elif (seconds / ( 60 * 60 )) | int > 6 %}
                over {{ (seconds //  ( 60 * 60 )) | int }} hours ago.
                {{ [
                'That is a crazy amount of time.', 
                'Did you decide you want those clothes to suffer?',
                'You might as well just rewash those clothes.',
                'I can smell the mildew. Virtually that is.',
                'Surely you did not mean to forget about the clothes.'
                ] | random }}
              {% else %}
                {{ (seconds // 60) | int }} minutes ago.
                {{ [
                'Do not forget to rotate the clothes.', 
                'Someone forgot to move the clothes to the dryer. I am not going to name names, but there is a camera in there. Do I need to publically shame someone?',
                'You might want to move them to the dryer.'
                ] | random }}
              {% endif %}
            </p>

  washer_idle:
    sequence:
      - service: mqtt.publish
        data:
          topic: house/washer/status
          payload: idle
          retain: true
  washer_running:
    sequence:
      - service: mqtt.publish
        data:
          topic: house/washer/status
          payload: running
          retain: true
  washer_complete:
    sequence:
      - service: mqtt.publish
        data:
          topic: house/washer/status
          payload: complete
          retain: true
      - service: mqtt.publish
        data:
          topic: house/washer/time_complete
          # payload: '{{ now().timestamp() }}'
          payload: "{{ utcnow().isoformat() }}"
          retain: true
########################
#################REMNANTS- AUTOMATIONS
########################
# - id: e1cb26fe-0423-11eb-adc1-0242ac120002
#   initial_state: true
#   alias: Dryer Notification
#   trigger:
#   - platform: state
#     entity_id: binary_sensor.dryer_dry_completed
#     from: 'off'
#     to: 'on'
#   action:
#   - service: script.status_annc
#     data:
#       who: '{{ states.sensor.room_presence.state }}'
#       call_interruption: 1
#       speech_message: It appears the dryer has finished.
#   - delay:
#       minutes: 15
#   # - service: script.turn_on
#   #   entity_id: script.dryer_finished_notification_audible

# - id: dishwasher_idle
#   initial_state: true
#   alias: Dishwasher Idle
#   trigger:
#   - platform: state
#     entity_id: device_tracker.dishwasher
#     to: 'not_home'
#   action:
#   - service: script.dishwasher_idle

# # When dishwasher connects to network assume it is running cycle.
# - id: dishwasher_running
#   initial_state: true
#   alias: Dishwasher Running
#   trigger:
#   - platform: state
#     entity_id: device_tracker.dishwasher
#     to: 'home'
#   action:
#   - service: script.dishwasher_running

########################
#################REMNANTS- SCRIPTS
########################

# dryer_finished_notification_audible:
#   sequence:
#   - repeat:
#       while:
#         - condition: state
#           entity_id: sensor.washer_status
#           state: 'complete'
#       sequence:
#       - service: script.dryer_audible
#       - delay:
#           minutes: 45

# dishwasher_idle:
#   sequence:
#   - service: mqtt.publish
#     data:
#       topic: house/dishwasher/status
#       payload: idle
#       retain: true
#
# dishwasher_running:
#   sequence:
#   - service: mqtt.publish
#     data:
#       topic: house/dishwasher/status
#       payload: running
#       retain: true

I have no idea why this isn’t working for you.

I copied your entire package contents above into my test config running 2022.9.2 and the validation check works fine. I used it with the new and old alternately commented out and both validate just fine.

EDIT:

wait…I just noticed I have something else strange going on…

I’ll gt back to you on this…

I haven’t (yet…) figured out what’s going on with my test setup but putting the code in there allowed me to notice one thing that might be an issue.

you marked your code with new and old sections and you say you have been alternating commenting and uncommenting the two.

but if you are then you still have one sensor that is left in the code but without the “sensor:” key to configure it.

here is the sensor section of the package I annotated with the possible issue (denoted by #<—):

#####/OLD######

sensor:                    #<---------------------- you still need this...
  # - platform: "mqtt"
    # name: "Washer Status"
    # state_topic: "house/washer/status"
  # - platform: "mqtt"
    # name: "Washer Last Complete"
    # state_topic: "house/washer/time_complete"
    # device_class: timestamp
  # - platform: "mqtt"
    # name: "Washer Last Emptied"
    # state_topic: "house/washer/time_emptied"
    # device_class: timestamp

#####/OLD######

  # - platform: mqtt_room
  #   device_id: 123testid
  #   state_topic: "espresense/rooms"

# One entry for each beacon you want to track
  - platform: mqtt_room                  #<------ for this...
    device_id: "apple:1006:10-8"
    name: 'Westons iPhone Room Presence'
    state_topic: 'espresense/devices/apple:1006:10-8'
    timeout: 10
    away_timeout: 120

Ahh, you may have caught the issue there!! Let me check this the next time I get back to my PC and I’ll report what I find out.

If I have other sections of the Mqtt sensor in that package, can I use the old code style on some and the new code style on some? I think this is what I was attempting to do and just need to move that “sensor:” farther down in the file to where more of the old Mqtt code style exists— unless I’m dreaming and there are not anymore.— in that case, I def need to comment it out like you’re thinking.

Let me mess with this, this evening and let’s see what happens.

Thank you so much @finity, this has been driving me bonkers.

1 Like

yes as far as I know. At least until the old style is completely deprecated in December.

OK, so I have messed with this a bit more tonight trying to simplify things to get to the bottom of whatever is going on. Below is my current package file that is causing the validator to never complete. See if you see any issues with this one. I believe I corrected what you were speaking of in your previous post but it seems like it still won’t validate for some reason. This is blowing my mind. (Currently below I have both the old code style and new code style in use)

Thank you for trying to help me figure this out. I really don’t understand what’s going on

input_boolean:
  washer_finished:
    name: Washer Finished
    icon: mdi:washing-machine
input_number:
  stepper_control_right_test_blind:
    name: Stepper Control Right Test Blind
    min: -200
    max: 460
    step: 1
    mode: slider
  stepper_control_left_test_blind:
    name: Stepper Control Left Test Blind
    min: -200
    max: 700
    step: 1
    mode: slider

#####NEW######

mqtt:
  sensor:
    - name: "Washer Status"
      state_topic: "house/washer/status"
    - name: "Washer Last Complete"
      state_topic: "house/washer/time_complete"
      device_class: timestamp
    - name: "Washer Last Emptied"
      state_topic: "house/washer/time_emptied"
      device_class: timestamp

#####/NEW######

#####/OLD######

sensor:
  # - platform: "mqtt"
  #   name: "Washer Status"
  #   state_topic: "house/washer/status"
  # - platform: "mqtt"
  #   name: "Washer Last Complete"
  #   state_topic: "house/washer/time_complete"
  #   device_class: timestamp
  # - platform: "mqtt"
  #   name: "Washer Last Emptied"
  #   state_topic: "house/washer/time_emptied"
  #   device_class: timestamp

    # # MQTT Sensor for DishWasher Status.
  # - platform: mqtt
  #   name: "DishWasher Status"
  #   state_topic: "house/dishwasher/status"
  # MQTT Sensor for Washing Machine Status.

# One entry for each beacon you want to track
  - platform: mqtt_room
    device_id: "apple:1006:10-8"
    name: 'Westons iPhone Room Presence'
    state_topic: 'espresense/devices/apple:1006:10-8'
    timeout: 10
    away_timeout: 120

    #####/OLD######

    ####NOT USING CURRENTLY####

  # - platform: mqtt_room
  #   device_id: 123testid
  #   state_topic: "espresense/rooms"

    ####/NOT USING CURRENTLY####

utility_meter:
  washer_daily_kwh:
    source: sensor.washer_switch_electric_consumed_kwh
    cycle: daily
  washer_weekly_kwh:
    source: sensor.washer_switch_electric_consumed_kwh
    cycle: weekly

automation:
  - id: washer_running
    alias: Washer Running
    trigger:
      - above: 4
        entity_id: sensor.washer_power_consumed_w
        platform: numeric_state
    condition:
      condition: or
      conditions:
        - condition: state
          entity_id: sensor.washer_status
          state: idle
        - condition: state
          entity_id: sensor.washer_status
          state: complete
    action:
      - service: mqtt.publish
        data:
          topic: house/washer/status
          payload: running
          retain: true
    initial_state: true

  - id: washer_complete
    alias: Washer Complete
    trigger:
      - below: 2
        entity_id: sensor.washer_power_consumed_w
        platform: numeric_state
    condition:
      - condition: state
        entity_id: sensor.washer_status
        state: running
    action:
      - service: mqtt.publish
        data:
          topic: house/washer/status
          payload: complete
          retain: true
      - service: mqtt.publish
        data:
          topic: house/washer/time_complete
          payload: "{{ utcnow().isoformat() }}"
          # payload: '{{ now().timestamp() }}'
          retain: true
    initial_state: true

  - id: washer_notification
    initial_state: true
    alias: Washer Notification
    trigger:
      - platform: state
        entity_id: sensor.washer_status
        from: running
        to: complete
    action:
      - service: script.speech_engine
        data:
          # who: 'kitchen'
          message: "Just a quick heads up, It appears the washing machine has completed its cycle"
      - service: script.text_notify
        data:
          who: parents
          title: Washing Machine Finished
          message: "Just a quick heads up, It appears the washing machine has completed its cycle"
          data:
          group: "appliances"
          tag:
      - service: script.turn_on
        entity_id: script.washer_finished_notification_audible
      - service: input_boolean.turn_on
        data: {}
        target:
          entity_id: input_boolean.washer_finished

  - id: washer_emptied
    initial_state: true
    alias: Washer Emptied
    trigger:
      - platform: state
        entity_id: binary_sensor.washer_door
        from: "off"
        to: "on"
    action:
      - service: mqtt.publish
        data:
          topic: house/washer/status
          payload: idle
          retain: true
      - service: script.turn_off
        entity_id: script.washer_finished_notification_audible
      - service: mqtt.publish
        data:
          topic: house/washer/time_emptied
          # payload: '{{ now().timestamp() }}'
          payload: "{{ utcnow().isoformat() }}"
          retain: true
      - service: input_boolean.turn_off
        data: {}
        target:
          entity_id: input_boolean.washer_finished

script:
  washer_finished_notification_audible:
    sequence:
      - repeat:
          while:
            - condition: state
              entity_id: sensor.washer_status
              state: "complete"
          sequence:
            - delay:
                minutes: 30
            - service: script.simplified_washer_audible

  simplified_washer_audible:
    sequence:
      - condition: state
        entity_id: group.family
        state: "home"
      - condition: state
        entity_id: sensor.washer_status
        state: complete
      - service: script.speech_engine
        data:
          # who: 'kitchen'
          message: >
            {{ [
              'Pardon me, ',
              'Excuse me, ',
              'I do not mean to interrupt, but,',
              'I hate to interrupt, but,',
              'I beg your pardon, ',
              'I do not mean to intrude, but, ',
              'I am sorry to interrupt, but. ',
              'Just a quick heads up, '
              ] | random }}
            <p>
              The washing machine completed its cycle 
              {% set seconds = now().timestamp() - as_timestamp(states.sensor.washer_status.last_changed) %}
              {% if (seconds / ( 60 * 60 )) | int == 1 %}
                over an hour ago.
                {{ [
                'Do not forget to rotate the clothes.', 
                'Was someone going to rotate the laundry?',
                'Once you rotate the laundry I will stop reminding you to do it. So if you want me to stop. Its up to you.'
                ] | random }}
              {% elif (seconds / ( 60 * 60 )) | int > 1 and (seconds / ( 60 * 60 )) | int < 6 %}
                over {{ (seconds //  ( 60 * 60 )) | int }} hours ago.
                {{ [
                'Much longer and you are going to need to wash them again.', 
                'Someone needs to rotate the laundry.',
                'Do not forget about the clothes in the washing machine.',
                'Surely you did not mean to forget about the clothes. Mistakes happen. But you can still fix it.',
                'Do you like your clothes smelling like mildew? Becasue that is what is happening right now.'
                ] | random }}
              {% elif (seconds / ( 60 * 60 )) | int > 6 %}
                over {{ (seconds //  ( 60 * 60 )) | int }} hours ago.
                {{ [
                'That is a crazy amount of time.', 
                'Did you decide you want those clothes to suffer?',
                'You might as well just rewash those clothes.',
                'I can smell the mildew. Virtually that is.',
                'Surely you did not mean to forget about the clothes.'
                ] | random }}
              {% else %}
                {{ (seconds // 60) | int }} minutes ago.
                {{ [
                'Do not forget to rotate the clothes.', 
                'Someone forgot to move the clothes to the dryer. I am not going to name names, but there is a camera in there. Do I need to publically shame someone?',
                'You might want to move them to the dryer.'
                ] | random }}
              {% endif %}
            </p>

  washer_idle:
    sequence:
      - service: mqtt.publish
        data:
          topic: house/washer/status
          payload: idle
          retain: true
  washer_running:
    sequence:
      - service: mqtt.publish
        data:
          topic: house/washer/status
          payload: running
          retain: true
  washer_complete:
    sequence:
      - service: mqtt.publish
        data:
          topic: house/washer/status
          payload: complete
          retain: true
      - service: mqtt.publish
        data:
          topic: house/washer/time_complete
          # payload: '{{ now().timestamp() }}'
          payload: "{{ utcnow().isoformat() }}"
          retain: true

Behavior can be seen at the screen recording linked below:

I finally got my production HA up to date (2022.9.7) and copied the above latest code directly into my config and it validates fine. So I really don’t know what might be going on with yours.

I’m fairly certain it’s not a bug in HA now, tho.

Oh geez. I had a bad feeling this would be the result.

Thank you for checking that last code for me.

I’m at a loss on this one then. It seems like when 2022.12 comes that I’ll be rebuilding my HA instance possibly. This is nuts.

You might be able to try to just comment everything out in that package file and add one section back in at a time until it fails.

then skip that section (leaving it commented out) and move on to the next.

then when you have it completely checked and hopefully narrowed down to the exact section that is failing then add a bit of the offending section back in until it fails again.

that might help get to a specific spot?

If I have other packages with Mqtt stuff in them. Could they be interfering somehow? They would be in the old format also. I think I have some blinds created in earphone that have a few Mqtt sensors being created in them but they are completely external to the Mqtt items in the package that we have been discussing.

I will try this. But I’m fairly certain I may have done this before and it worked fine until I uncommented the last section (which was the “new” code section)— I’ll give this idea another try tomorrow and see if I hopefully get a different result.

Thank you for the idea.

1 Like

They shouldn’t interfere as far as I know.

I had old and new style MQTT stuff configured together and in different packages and it worked fine. At least in older versions of HA.