MQTT breaks on migration

I upgraded my hardware to a tinkerboard from a PI today. Created a snapshot in HASSIO and moved that over and all started to work except my MQTT lights. I created a MQTT entry for this and it sends MQTT topics to my UniPi system where a custom scripts receives the message, takes actions and ack’s a MQTT message back so the light turns yellow in the HassIO GUI.

All works fine except that HASSIO does not accept the response MQTT message on the migrated HASSIO on the thinkerboard, but it does work on the PI (migrated back for now, works again).

Love to hear idea’s here.

MQTT light code is:

- platform: mqtt_template
  # based on; https://github.com/bruhautomation/BRUH3-Home-Assistant-Configuration/blob/master/lights/mqtt_lights/jar_leds_template.yaml
  name: "Achterdeur light"
  state_topic: "homeassistant/buiten/achterdeur/licht"
  command_topic: "homeassistant/buiten/achterdeur/licht/set"
  availability_topic: "homeassistant/buiten/achterdeur/licht/available"
  payload_available: "online"
  payload_not_available: "offline"
  brightness_state_topic: "homeassistant/buiten/achterdeur/licht/brightness"
  command_on_template: >
    {"state": "on"
    , "circuit": "2_01"
    , "dev": "analogoutput"
    {%- if brightness is defined -%}
    , "brightness": {{ brightness }}
    {%- elif brightness is undefined -%}
    , "brightness": 100
    {%- endif -%}
    {%- if effect is defined -%}
    , "effect": "{{ effect }}"
    {%- endif -%}
    {%- if transition is defined -%}
    , "transition": {{ transition }}
    {%- endif -%}
    }
  command_off_template: '{"state": "off", "circuit": "2_01", "dev": "analogoutput"}'
  state_template: '{{ value_json.state }}'
  brightness_template: '{{ value_json.brightness }}'
  on_command_type: "brightness"
  #red_template: '{{ value_json.color[0] }}'
  #green_template: '{{ value_json.color[1] }}'
  #blue_template: '{{ value_json.color[2] }}'
  #effect_template: '{{ value_json.effect }}'
  qos: 0
  homebridge_hidden: false

The message that is send and returned is:

{"state": "on" , "circuit": "2_01" , "dev": "analogoutput"}

Does the response message reach the broker on the tinkerboard? It is best to check using another client, such as mosquitto_sub

And can you format your yaml using the instructions in the big blue box at the top of the page, so the indentation is clear.

Hi, thanks for your prompt response. I used MQTT fx to listen to all traffic on Mosquitto and I see the original and reply request passing by there. State topic seems to be correct. I changed i back for now (wife thing) I will try again tomorrow and dump some screens.

Or do you want me to check in a different place?

That is fine. I was just making sure that the problem was really in the HA handling of the response. There was no point in looking if the message hadn’t got there.:smile:

Okay, I have been doing some more research here and it appears that MQTT works, but not for the templates I use for light switches.

  • Updates I receive from other MQTT devices get updated in hassio
  • non-template MQTT devices (like switch example below) work fine
    - platform: mqtt
      name: "Bijkeuken Dakraam"
      state_topic: "homeassistant/bijkeuken/dakraam/sluiten"
      command_topic: "homeassistant/bijkeuken/dakraam/sluiten/set"
      availability_topic: "homeassistant/bijkeuken/dakraam/sluiten/available"
      payload_available: "online"
      payload_not_available: "offline"
      payload_on: '{"state": "on", "circuit": "1_02", "dev": "output", "duration": 25}'
      payload_off: '{"state": "on", "circuit": "1_01", "dev": "output", "duration": 35}'
      qos: 0
      homebridge_hidden: false
      icon: mdi:window-closed
      retain: true

Can someone help me troubleshoot the template that I posted on top? No idea where to start. Like posted, this is from a snapshot back-up, only different hardware. I checked the version numbers of all components, they are the same. How can I check 64 vs 32 bit? Might be a difference here. thanks again!

Hi. Upgrading to 0.76 made it work. Thanks for the support.

1 Like