MQTT Raw sensor, that has --- state

Hi there,
I have multiple MQTT sensors from BSB-LAN, as RAW.
I need help configure sensor of pump power.

  - state_topic: "BSB-LAN/8308"
    name: BSB-LAN Boiler pump speed
    unique_id: bsb_lan_boiler_pump_speed
    availability_topic: "BSB-LAN/status"
    unit_of_measurement: "%"
    device_class: power_factor

And if pump not run, I have a state of payload as “—” (three lines).
In this situation, I need have a value 0 (zero), in other case a value of a sensor.
Thank for help.

value_template: "{{ value.replace('---', '0') }}"
1 Like

Great!!! It works.
Thank you very much.

1 Like

@jirka.jirutka How did you solve this?
i have several values coming from BSB-Lan which are returning — from time to time.
Is there a generic solution for all BSB-LAN Entities? I want to log all incoming values to influxDB and this is causing troubles…

Or do i need to add each entity to the configuration.yaml?

Would this work?

yeah! got it to work :slight_smile: i did set the name to null.

mqtt:
    sensor:
    - name: null
      state_topic: "BSB-LAN/0"
      value_template: "{{ value.replace('---', '0') }}"

:frowning: It failed again

mqtt:
    sensor:
      state_topic: "BSB-LAN/0"
      value_template: "{{ value.replace('---', '0') }}"

Seems like there is no option to replace all values for all entities?
There are about 40-50 entities, which i like to push into the influxDB but they are sent as — from time to time.

That’s a byte string not a normal string, hence the b'---'.

If it’s always meant to be a number, just use {{ value|float(0) }}

@Troon Thanks!
always float is fine. unfortunately its again throwing the error.
is it even possible to use it through an overall topic? Or do i need to set it for each entity individually?


This is unfortunately the same error:

You need to set it for each. The error message in your screenshot references a different MQTT topic to the sensor configuration…

Thanks Troon! I got it working :slight_smile:

sensor:
  - name: "bsb_lan_00_20_luftung_1_8951_schienenvorlauftemperatur_sollwert"
    state_topic: "BSB-LAN/0/20/8951/status"
    value_template: "{{ value.replace('---', '0') }}"
    state_class: measurement
    unit_of_measurement: °C
    icon: mdi:thermometer

I also stopped the auto discovery for that sensor. Now the value comes in as 0 instead of “- - -”

Now i just need to do that for all other values :smiley: