Cannot get desired numeric result out of a complex MQTT response

Hello there,

I am facing a problem that I cannot resolve. I use open3e to get readings from my heat pump. The results are then broadcasted via MQTT to my HA Installation. Unfortunately there is data that I cannot extract to use it as values for a sensor.

open3e result is:
vcal 274 OutsideTemperatureSensor {"Actual": 5.3, "Minimum": 4.8, "Maximum": 5.4, "Average": 4.8, "Unknown": 0}

the sensor in the configuration.yaml as follows:

 - state_topic: open3e/vitocal/274_OutsideTemperatureSensor/Actual
    unit_of_measurement: "°C"
    name: "Aussentemperatur"
    unique_id: "Aussentemperatur"
    device:
      name: "Vitocal 250"
      identifiers:
        - "vitocal_250"

This results in the Value
"Unknown"
of the sensor entity.

Where is the mistake I am making over and over again?

Regards,

Alex

Hello riessal,

Troubleshooting MQTT? MQTT-Explorer can help you be successful!
If you have Add-ons available, try adding this Add-on repository to your Add-on list. GitHub - GollumDom/addon-repository.
Using that you can better see what the topics are and what they need to be.

Hello @Sir_Goodenough,

Thank you for your fast response. I have the MQTT-Explorer running (see the screenshot). Unfortunately it doesnt help me solving my problem.

I need the numeric value of “Actual” but only get an “Unknown”, not the “0”.

That’s the topic I think. Actual is part of the JSON of the value you are looking for.
value_json.Actual

Needs something like this…

    state_topic: "open3e/vitocal/274_OutsideTemperatureSensor"
    state_value_template: "{{ value_json.Actual }}"
1 Like

Unfortunately state_value_template cannot be parsed.

But if I use the topic “open3e/vitocal/0274_OutsideTemperatureSensor/Actual” shouldn’t that give me a numeric result?


your indentation is wrong.

Thank you for the hint. Would this be correct?

state_topic: open3e/vitocal/274_OutsideTemperatureSensor/Actual
    unit_of_measurement: "°C"
    name: "Aussentemperatur"
    unique_id: "Aussentemperatur"
    device:
      name: "Vitocal 250"
      identifiers: "vitocal_250"

    - name: "turned on"
      state_topic: "pump/timestamp_on"
      device_class: "timestamp"
      value_template: "{{ as_datetime(value) }}"
      unique_id: "hp_1231232_ts_on"
      device:
        name: "Heat pump"
        identifiers:
          - "hp_1231232"

From the integration page. Copy and paste on my phone is causing indentation errors as well.

No.

the data is held in the topic.

the topic is “open3e/vitocal/0274_OutsideTemperatureSensor”.

the data is held in “key:value” pairs inside the topic

the key for the value you want from the above topic is “Actual”.

you have to extract that value by passing the resulting json string from the topic thru a template.

If you paste this into the dev tools template editor and play around with the part inside the {{ }} you should see how it works:

{% set value_json = {"Actual": 5.3, "Minimum": 4.8, "Maximum": 5.4, "Average": 4.8, "Unknown": 0} %}

{{ value_json.Actual }}

you were close.

We are assuming that they are creating an MQTT sensor so it should actually be:

state_topic: "open3e/vitocal/274_OutsideTemperatureSensor"
value_template: "{{ value_json.Actual }}"

So full config should look something like:

mqtt:
  sensor:
    - state_topic: "open3e/vitocal/274_OutsideTemperatureSensor"
      value_template: "{{ value_json.Actual }}"
      unit_of_measurement: "°C"
      name: "Aussentemperatur"
      unique_id: "Aussentemperatur"
      device:
        name: "Vitocal 250"
        identifiers:
          - "vitocal_250"
1 Like

Thank you so much, now it works!

2 Likes