Mqtt Issues, devices stop showing up in blueprints

Hello, I’m now rather tired of HA integrations stopping working etc out of nowhere.

Here are 2 screenshots and a blueprint script, how come the working screenshot works while the other suddenly stopped working and prevents me from readding the device?

[Working blueprint config]

[Just stopped working and I cannot add the device “sensors/motion/hallway/aqara_0”]

The blueprint source is as follows, keep in mind, this has worked for 2 years and just now I’ve started to get more and more of these errors and I cannot find any documentation or any information as to why they stop working

blueprint:
  name: Advanced Motion Lights
  description: Motion controlled lights based on illumination and time of day
  domain: automation
  input:
    motion_entity:
      name: Motion Sensor
      selector:
        entity:
          filter:
            domain: binary_sensor
            device_class: motion
          multiple: true
    illumination_entity:
      name: Illumination Sensor (Optional)
      default: {}
      selector:
        entity:
          filter:
            device_class: illuminance
    daytime_lights_entity:
      name: Day lights
      description: Lights to turn on durring the day
      selector:
        target:
          entity:
            domain: light
    nighttime_lights_entity:
      name: Night lights
      description: Lights to turn on durring the night
      selector:
        target:
          entity:
            domain: light
    daytime:
      name: Day time
      description: Time when the day starts
      default: "08:00:00"
      selector:
        time:
    nighttime:
      name: Night time
      description: Time when the day ends
      default: "21:00:00"
      selector:
        time:
    nighttime_brightness:
      name: Night time brightness
      description: Brightness for lights on nighttime.
      default: 40
      selector:
        number:
          max: 100
          min: 0
          unit_of_measurement: "%"
    daytime_brightness:
      name: Daytime brightness
      description: Brightness for lights on daytime.
      default: 100
      selector:
        number:
          max: 100
          min: 0
          unit_of_measurement: "%"
    daytime_temp:
      name: Daytime temperature
      description: The color warmth for the daytime
      default: 175
      selector:
        color_temp:
    nighttime_temp:
      name: Nighttime temperature
      description: The color warmth for the nighttime
      default: 475
      selector:
        color_temp:
    daytime_motion_timeout:
      name: Day time on timeout
      description: Time to leave the light on after last motion is detected when it's day.
      default: 900
      selector:
        number:
          min: 0
          max: 3600
          unit_of_measurement: seconds
    nighttime_motion_timeout:
      name: Night time on timeout
      description: Time to leave the light on after last motion is detected when it's night.
      default: 300
      selector:
        number:
          min: 0
          max: 3600
          unit_of_measurement: seconds
    brightness_treshold:
      name: Lux Treshold
      default: 145
      selector:
        number:
          max: 1000.0
          min: 0
          unit_of_measurement: "lux"
          mode: slider

# If motion is detected within the delay,
# we restart the script.
mode: restart
max_exceeded: silent

triggers:
  trigger: state
  entity_id: !input motion_entity
  from: "off"
  to: "on"

action:
  - variables:
      daytime_lights: !input daytime_lights_entity
      nighttime_lights: !input nighttime_lights_entity
      motion_state: "{{ trigger.from_state.state }}"
      day_time: !input "daytime"
      night_time: !input "nighttime"
      brightness_day: !input daytime_brightness
      brightness_night: !input nighttime_brightness
      no_motion_wait_day: !input daytime_motion_timeout
      no_motion_wait_night: !input nighttime_motion_timeout
      color_temp_day: !input daytime_temp
      color_temp_night: !input nighttime_temp
      is_day: "{{now().hour >= strptime(day_time, '%H:%M:%S').hour and now().hour < strptime(night_time, '%H:%M:%S').hour}}"
      is_night: "{{ now().hour < strptime(day_time, '%H:%M:%S').hour or now().hour >= strptime(night_time, '%H:%M:%S').hour}}"

      lights: |
        {%
          if now().hour >= strptime(day_time, '%H:%M:%S').hour and 
          now().hour < strptime(night_time, '%H:%M:%S').hour
        %}
        {{ daytime_lights}}
        {% else %}
        {{ nighttime_lights }}
        {% endif %}
      brightness: |
        {%
          if now().hour >= strptime(day_time, '%H:%M:%S').hour and 
          now().hour < strptime(night_time, '%H:%M:%S').hour
        %}
        {{ brightness_day }}
        {% else %}
        {{ brightness_night }}
        {% endif %}
      color_temp: >
        {%
          if now().hour >= strptime(day_time, '%H:%M:%S').hour and 
          now().hour < strptime(night_time, '%H:%M:%S').hour
        %}
        {{ color_temp_day }}
        {% else %}
        {{ color_temp_night }}
        {% endif %}
      no_motion_wait: |
        {%
          if now().hour >= strptime(day_time, '%H:%M:%S').hour and 
          now().hour < strptime(night_time, '%H:%M:%S').hour
        %}
        {{ no_motion_wait_day }}
        {% else %}
        {{ no_motion_wait_night }}
        {% endif %}
  - alias: "Check if it's dark enough to turn on the lights"
    if:
      - condition: numeric_state
        entity_id: !input "illumination_entity"
        below: !input "brightness_treshold"
    then:
      - action: light.turn_on
        target: "{{lights}}"
        data:
          brightness_pct: "{{ brightness }}"
          color_temp: "{{ color_temp }}"
    else:
      - action: light.turn_off
        target: "{{lights}}"
  - wait_for_trigger:
      trigger: state
      entity_id: !input motion_entity
      from: "on"
      to: "off"
  - delay: "{{ no_motion_wait }}"
  - action: light.turn_off
    target: "{{lights}}"

hi

first of you should

  1. open mqtt device in the devices.
    example


and check is all entities here.

  1. click MQTT INFO
    and deep to information.

for example as you can see
I have device_class: occupancy not device_class: motion as you expected.

and last one. if you develop a common solution, please be sure what you should support

    | selectattr('attributes.device_class', 'in', ['motion', 'occupancy', 'presence'])

I ended up re-syncing the devices 5 times and restoring a backup from 7 days ago just in case there’s been an update I’ve missed and eventually, after much struggle managed to get it to work although there seems to have been 2 updates that I had missed that could have caused this so it will just have to be a headache for me tomorrow instead.

Super thanks for the feedback though, I will double-check those suggestions in case I get the issues again and try to figure out what the root cause is :slight_smile:

1 Like

btw, let me hug you :slight_smile: i feel your pain, Sir! xmas - nye updates for HASS was crazy :frowning:

1 Like