Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 108213

MQTT topic payload for sensor

$
0
0

Hi,
I’ve a Switchbot lock that posts following topic in the MQTT broker:

homeassistant/binary_sensor/both_lockState_FF11FF22FF33/config

This topic shows the payload as:

{
  "value_template": "{{ value_json['lockState'] if (value_json['lockState'] is defined and value_json['lockState'] is not none) else states('sensor.both_lockState_FF11FF22FF33') }}",
  "state_topic": "switchbot/FF11FF22FF33/status",
  "payload_on": "unlocked",
  "payload_off": "locked",
  "name": "lockState",
  "unique_id": "both_lockState_FF11FF22FF33",
  "object_id": "both_lockState_FF11FF22FF33",
  "device": {
    "identifiers": ["FF11FF22FF33"],
    "name": "Front Door Lock",
    "manufacturer": "SwitchBot",
    "model": "Smart Lock"
  },
  "device_class": "lock"
}

Also created this code in the config.yaml but it always shows value as “unknown”:

mqtt:
  binary_sensor:
    - name: 'Front Door Lock Status'
      state_topic: "homeassistant/binary_sensor/both_lockState_FF11FF22FF33/config"
      device_class: lock
      payload_available: "unlocked"
      payload_not_available: "locked"

Please let me know if anyone can point me in the right direction.
Thanks.

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 108213

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>