0

i’m trying to configure my deebot robot with mqtt using the Node-Red integration. I managed to configure everything on Node-red, but i can’t split values from the mqtt message. This is what i get from the( i get many payloads with the same topic):

{"type":"CurrentUsedCustomAreaValues","value":""}
{"type":"CurrentUsedSpotAreas","value":""}
{"type":"CleanReport","value":"stop"}
{"type":"ChargeState","value":"charging"}
{"type":"SleepStatus","value":"1"}
{"type":"LifeSpan","value":{"filter":83.93,"side_brush":-0.42,"main_brush":51.92}}
{"type":"BatteryInfo","value":100,"unit":"%"}

This is how i tried to retrive the data to sensors in configuration.yaml but it's not working, i always get "unknown" sensor value

mqtt:
  sensor:
    - name: "filter_left"
      state_topic: "vacuum/sensors"
      unit_of_measurement: "h"
      value_template: "{{ value_json['value'].filter }}"
    - name: "main_brush_left"
      state_topic: "vacuum/sensors"
      unit_of_measurement: "h"
      value_template: "{{ value_json['value'].main_brush }}"  
    - name: "side_brush_left"
      state_topic: "vacuum/sensors"
      unit_of_measurement: "h"
      value_template: "{{ value_json['value'].side_brush }}"
    - name: "vacuum_battery"
      state_topic: "vacuum/sensors"
      unit_of_measurement: "%"
      value_template: "{{value_json.type.BatteryInfo}}"

Thanks in advance for any help

1 Answers1

0

It looks like your main issue is that the MQTT message isn't valid JSON. If you take that LifeSpan line, for example, and plug it in to the template tool on Home Assistant (http://your-ha-machine.local:8123/developer-tools/template), you could insert the contents of that line (minus the curly braces), like this:

{% set my_test_json = {
"type":"LifeSpan","value":{"filter":83.93,"side_brush":-0.42,"main_brush":51.92}
}
%}

The filter life is at {{ my_test_json.value.filter }}.

You can use that tool to play around with the formatting, and figure out what's wrong with the syntax. You'll probably need to fix the MQTT message on the Node-Red side.