Help needed for MQTT Binary Sensor

I want to create an MQTT binary sensor:

Topic: BlueIris/status
Message: signal=1 profile=1 lock=1 schedule=Default

If The value profile=1 in the MQTT Message sensor should be on, if the value profile=0 in the MQTT Message sensor should be off.
Can anyone help me please ?

Is that the actual format of the message?

Or does it use json?

Hello,

Yes that is the format, no JSON …

image

binary_sensor:
- platform: mqtt
  state_topic: "BlueIris/status"
  name: "Blue Iris Profile"
  payload_on: '1'
  payload_off: '0'
  value_template: "{{ value.split(' ')[1].split('=')[1] }}"
  qos: 1
1 Like

Thanks for your Help, but it does not work …
See following Error in Log:

Logger: homeassistant.helpers.template
Source: helpers/template.py:557
First occurred: 10:54:18 (5 occurrences)
Last logged: 10:59:46

  • Error parsing value: list object has no element 1 (value: signal=1 profile=0 lock=1 schedule=Default , template: {{ value.split(’ ‘)[1].split(’=’)[1] }})
  • Error parsing value: list object has no element 1 (value: signal=1 profile=1 lock=1 schedule=Default , template: {{ value.split(’ ‘)[1].split(’=’)[1] }})

This Code is workinf for me now:
I removed the ’ ’ in value.split(’ ')

  • platform: mqtt
    state_topic: “BlueIris/status”
    name: “Blue Iris Profile”
    payload_on: ‘0’
    payload_off: ‘1’
    value_template: “{{ value.split()[1].split(‘=’)[1] }}”
    device_class: safety
    qos: 1

Thanks for your Help !

Hello! Glad you got it working.

Please note that you should mark the post that help you solve your problem. Please refer to this.

You can mark tom_l post as the solution.

1 Like

Maybe you used “fancy” quotes?

e.g. instead of '

It does the same thing:

Hello, i copy & paste your Code.
In The Template Editor it works for me too, but not in configuration.yaml.

:man_shrugging: Weird. Oh well it’s working which is the main thing :+1:

Ahh. Unless they are not spaces. Could be tabs.

1 Like

If you’re a fan of regex:

value_template: "{{ value | regex_findall_index('profile=([0,1])') }}"
1 Like