Parsing complex MQTT message from WLANTHERMO

I want to integrate my WLANTHERMO into my home assistant configuration. This is a BBW thermometer that is sending Mqtt messages which should make an easy integration possible. I see potential 10 entities:

  • The thermometer which i.e. provides riss and battery voltage
  • 8 probes that i.e. provide current temperature, lower and higher limits and probably alerts when the current temperature exceeds the limits
  • The fan control that i.e. controls the fan

I have added a platform template, but I am failing in getting all the values into my entities.

Things I do not get working:

  • I want to map the unit from system into each off the channels.

  • I want to map unit, charge, riss, online, … into additional attributes of the entity of the device

  • I want to map min and max as attributes into the entity of the temp sensor

    - platform: mqtt
      name: "WLANThermo"
      state_topic: "WLanThermo/NANO-84aaaa/status/data"
      unit_of_measurement: ''
      value_template: "{{ value_json['system']['online'] }}"
      json_attributes:
        - time: "{{ value_json['system']['time'] }}"
    - platform: mqtt
      name: "WLANThermo_Sensor1"
      state_topic: "WLanThermo/NANO-84aaaa/status/data"
      unit_of_measurement: "C"
      value_template: "{{ value_json['channel'][0]['temp'] }}"
    - platform: mqtt
      name: "..."
    - platform: mqtt
      name: "WLANThermo_Fan"
      state_topic: "WLanThermo/NANO-84aaaa/status/data"
      unit_of_measurement: ''
      value_template: "{{ value_json['pitmaster']['pm'][0]['typ'] }}"
    

This is the Mqtt message which I’ve converted into YAML. I have removed the sensors 2-8 in this example to keep it more compact. I did also attach how the entities are built in ha.

    system:
      time: '1546367291'
      unit: C
      soc: 50
      charge: false
      rssi: -60
      online: 1
    channel:
    - number: 1
      name: Kanal 1
      typ: 3
      temp: 23.1
      min: 10
      max: 35
      alarm: 0
      color: "#0C4C88"
    - number: 2
      name: ...
    pitmaster:
      type:
      - 'off'
      - manual
      - auto
      pm:
      - id: 0
        channel: 1
        pid: 0
        value: 0
        set: 50
        typ: 'off'
        set_color: "#ff0000"
        value_color: "#000000"

I’m don’t really understand the rest of your requirements, but json_attributes only works on top level of a structure - you cannot pick out elements beneath that. For instance, it can only do value_json["system"]

Thank you, that helps for the attributes. That applies for most of the questions.

On the other requirements I want to set the unit_of_measurement of cannel[0] to the value that can be found at system.unit. I assume that unit_of_measurement doesn’t support templates, therefore I cannot pull that information from system.unit, right?

It is difficult to say anything is impossible, but I have never seen anyone try and use templates with unit_of_measurement.