Read only "switch"

I want to have a read only boolean indicator which has a state and is being set by an MQTT device i built to track in grafana. i am currently using a switch, which is the closest thing i found, but i don’t need the “command_topic” as it is readonly so i just put NULL string there - is there any suggested alternative to this?

  switch:
    - platform: mqtt
      name: 'Lamp Awake Mode State'
      state_topic: "home/lamp/awake"
      command_topic: "NULL"
      payload_on: '1'
      payload_off: '0'

i thought about “input_boolean” but it does not the set state feature for incoming payload which is what i need.

For read only use an mqtt binary sensor rather than a switch.

binary_sensor: 
  - platform: mqtt
    name: Lamp Awake Mode State
    state_topic: "home/lamp/awake"
    payload_on: '1'
    payload_off: '0'

Thanks - works great :slight_smile:

1 Like