Mqtt entities

Hi all,
I’m trying to get an older configuration running but only one of my manually-configured MQTT devices show up as an entity. I think I’m just missing some detail in the config files. I’m hoping some kind soul will look at my config files and point out the issue.

One interesting thing is that the only MQTT device that shows up is the MBR Bath Fan. I have no idea why that one device shows up, as far as I can see this one is defined the same as the others.

Thanks in advance,
Bill

my configuration.yaml - note most of the commented-out stuff used to work but now throws errors.

homeassistant:
  name: The Shaw Estate
  latitude: !secret secret_lat
  longitude: !secret secret_long
  elevation: 239
  unit_system: imperial
  time_zone: America/New_York

#  customize: !include customize.yaml

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

weather:
  - platform: darksky
    api_key: !secret darksky_key
    
frontend:
#  javascript_version: latest
  themes: !include themes.yaml
#  extra_html_url: /local/custom_ui/state-card-floorplan.html
  
# Show the introduction message on startup.
#introduction: Welcome to the Shaw Estate.

# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# http:
#   base_url: example.duckdns.org:8123

# Discover some devices automatically
discovery:

recorder:
  # Delete events and states older than 1 week
#  purge_keep_days: 7
#  purge_interval: 3
#  db_url: !secret db_url
  commit_interval: 15
 
# Enables support for tracking state changes over time
history:

# enable ios integration
#ios:

# View all events in a logbook
logbook:

 # add logging for mysensor
logger:
  default: info
  logs:
    homeassistant.components.binary_sensors: debug
#mysensors: debug

# Enables a map showing the location of tracked devices
map:

# Track the sun
sun:

mqtt: !include mqtt.yaml

#panel_custom:
#  - name: floorplan
#    sidebar_title: Floorplan
#    sidebar_icon: mdi:home
# if you change the name of your floorplan.svg file, change it here too.
#    url_path: /local/custom_ui
#    js_url: /local/custom_ui/floorplan.html
#    config: !include floorplan.yaml
    
#panel_iframe:
#  configurator:
#    title: Configurator
#    icon: mdi:wrench
#    url: http://192.168.1.64:3218

#binary_sensor: !include binary_sensors.yaml
#sensor: !include sensors.yaml
#switch: !include switches.yaml

#  people tracker
#device_tracker:
#  - platform: ping
#    interval_seconds: 30
#    consider_home: 600
#    hosts:
#      dads_iphone:     192.168.1.110
#      yomammas_iphone: 192.168.1.122
#      wills_iphone:    192.168.1.108
#      cursed_images:   192.168.1.123
#      darios_iphone:   192.168.1.101

#  - platform: netgear
#    host: 192.168.1.1
#    username: !secret router_user
#    password: !secret router_pass
#    interval_seconds: 15
#    consider_home: 600

# Denon Receiver configuration
#media_player:
#  - title: "Denon AVR"
#    platform: denonavr
#    host: 192.168.1.14
#    name: Denon
#    show_all_sources: true
#    timeout: 2
#    zones:
#      - zone: Zone2
#        name: MBR
#      - zone: Zone3
#        name: Garage
        
speedtestdotnet:
  monitored_conditions:
    - ping
    - upload
    - download
  scan_interval:
    minutes: 360

#  - platform: ddwrt
#    host: 192.168.1.1
#    username: !secret router_user
#    password: !secret router_pass
#    interval_seconds: 15
#    consider_home: 180
#    new_device_defaults:
#      track_new_devices: true
#
# CJB_1 Switches (relay outputs)
#switch:

# Text to speech
#tts:
#  - platform: google

group:      !include groups.yaml
automation: !include automations.yaml
script:     !include scripts.yaml

eof

my mqtt.yaml -

#################################################################
##
## Switches for the Shaw Estate
##
#################################################################
#    value_template: "{{ value_json.temperature }}"
#    value_template: >
#      {
#         "switch": {{ value_json.switch }}
#      }  

#  discovery: true
#  discovery_prefix: hass

switch:
# -  unique_id: mqtt.switch.sonoff_1
 -  object_id: mqtt.switch.sonoff_1
    name: "Stairs Accent"
    icon: mdi:light
    command_topic: 'sonoff_1/switch'
    payload_on: '{"switch":"ON"}'
    payload_off: '{"switch":"OFF"}'
    state_topic: 'sonoff_1/status'
    state_on:  '{"switch":"ON"}'
    state_off: '{"switch":"OFF"}'
    qos: 2
    retain: true

switch:
 -  unique_id: mqtt.switch.sonoff_2
    object_id: mqtt.switch.sonoff_2
    name: "Living Room Lamp"
    icon: mdi:light
    command_topic: 'sonoff_2/switch'
    payload_on: '{"switch":"ON"}'
    payload_off: '{"switch":"OFF"}'
    state_topic: 'sonoff_2/status'
    state_on:  '{"switch":"ON"}'
    state_off: '{"switch":"OFF"}'
    qos: 2
    retain: true

switch:
 -  unique_id: mqtt.switch.kitchen_leds
    object_id: mqtt.switch.kitchen_leds
    name: "Kitchen Leds"
    icon: mdi:light
    command_topic: 'kitchen/leds'
    payload_on: '{"set_color":"white"}'
    payload_off: '{"set_bright":"off"}'
#    - payload_cycle: '{"set_color":"cycle"}'
    state_topic: 'kitchen/status'
    state_on:  '{"color":"white","bright":"full"}'
    state_off: '{"color":"white","bright":"off"}'
    qos: 2
    retain: true

switch:
 -  unique_id: front_lock
    object_id: front_lock
    name: "Front Lock"
    icon: mdi:lock
    command_topic: 'deadbolt_1/bolt'
    payload_on: '{"bolt":"lock"}'
    payload_off: '{"bolt":"unlock"}'
    state_topic: 'deadbolt_1/status'
    state_on:  '{"bolt":"locked"}'
    state_off: '{"bolt":"unlocked"}'
    qos: 2
    retain: true

switch:
 -  unique_id: sonoff_3
    object_id: sonoff_3
    name: "Bedside_Lamp"
    icon: mdi:light
    command_topic: 'sonoff_3/switch'
    payload_on: '{"switch":"ON"}'
    payload_off: '{"switch":"OFF"}'
    state_topic: 'sonoff_3/status'
    state_on:  '{"switch":"ON"}'
    state_off: '{"switch":"OFF"}'
    qos: 2
    retain: true

switch:
 -  unique_id: lower_bath_fan
    object_id: lower_bath_fan
    name: "Lower_Bath_Fan"
    icon: mdi:fan
    command_topic: 'lower_bath_fan/fan'
    payload_on: '{"switch":"ON"}'
    payload_off: '{"switch":"OFF"}'
    state_topic: 'lower_bath_fan/state'
 #    value_template: "{{value_json.switch}}"
    state_on:  '{"switch":"ON"}'
    state_off: '{"switch":"OFF"}'
    qos: 2
    retain: true

switch:
 -  unique_id: mbr_bath_fan
    object_id: mbr_bath_fan
    name: "MBR_Bath_Fan"
    icon: mdi:fan
    command_topic: 'mbr_bath_fan/fan'
    payload_on: '{"switch":"ON"}'
    payload_off: '{"switch":"OFF"}'
    state_topic: 'mbr_bath_fan/state'
#    value_template: "{{value_json.switch}}"
    state_on:  '{"switch":"ON"}'
    state_off: '{"switch":"OFF"}'
    qos: 2
    retain: true
    
binary_sensor:
  - name: "Clothes Washer"
    state_topic: "Washer_room/washer"
    value_template: "{{value_json.state}}"

binary_sensor:
  - name: "Clothes Dryer"
    state_topic: "Washer_room/dryer"
    value_template: "{{value_json.state}}"

binary_sensor:
  - name: "Water Room Wet Sensor"
    state_topic: "Water_room/water_sensor"
    value_template: "{{value_json.state}}"

binary_sensor:
  - name: "Washer room wet sensor"
    state_topic: "Washer_room/water_sensor"
    value_template: "{{value_json.state}}"

binary_sensor:
  - name: "Lower Bath Fan"
    state_topic: "lower_bath_fan/state"
    value_template: "{{value_json.switch}}"

binary_sensor:
  - name: "Master Bath Fan"
    state_topic: "mbr_bath_fan/state"
    value_template: "{{value_json.switch}}"

# CJB IR motion detector inputs
binary_sensor:
  - name: "Cellar"
    state_topic: "cjb_1/ir_1"
    value_template: "{{value_json.state}}"
    device_class: motion

binary_sensor:
  - name: "Lower Hall"
    state_topic: "cjb_1/ir_2"
    value_template: "{{value_json.state}}"
    device_class: motion

binary_sensor:
  - name: "Cellar Stairs"
    state_topic: "cjb_1/ir_3"
    value_template: "{{value_json.state}}"
    device_class: motion

binary_sensor:
  - name: "Computer Room"
    state_topic: "cjb_1/ir_4"
    value_template: "{{ value_json.state }}"
    device_class: motion

binary_sensor:
  - name: "Living Room"
    state_topic: "cjb_1/ir_5"
    value_template: "{{ value_json.state }}"
    device_class: motion

binary_sensor:
  - name: "Garage"
    state_topic: "cjb_1/ir_6"
    value_template: "{{ value_json.state }}"
    device_class: motion

binary_sensor:
  - name: "MBR Stairs"
    state_topic: "cjb_1/ir_9"
    value_template: "{{ value_json.state }}"
    device_class: motion

binary_sensor:
  - name: "Solarium"
    state_topic: "cjb_1/ir_10"
    value_template: "{{ value_json.state }}"
    device_class: motion

binary_sensor:
  - name: "MBR Bath"
    state_topic: "cjb_1/ir_11"
    value_template: "{{ value_json.state }}"
    device_class: motion

binary_sensor:
  - name: "MBR"
    state_topic: "cjb_1/ir_12"
    value_template: "{{ value_json.state }}"
    device_class: motion

binary_sensor:
  - name: "Kitchen"
    state_topic: "cjb_1/ir_13"
    value_template: "{{ value_json.state }}"
    device_class: motion

binary_sensor:
  - name: "Guest Room"
    state_topic: "cjb_1/ir_14"
    value_template: "{{ value_json.state }}"
    device_class: motion

# CJB switch inputs
binary_sensor:
  - name: "Rear door"
    state_topic: "cjb_1/switch_1"
    value_template: "{{ value_json.state }}"
    device_class: door

binary_sensor:
  - name: "Maddy's Window"
    state_topic: "cjb_1/switch_2"
    value_template: "{{ value_json.state }}"
    device_class: window

binary_sensor:
  - name: "Cellar Door"
    state_topic: "cjb_1/switch_3"
    value_template: "{{ value_json.state }}"
    device_class: door

binary_sensor:
  - name: "Alcove Door"
    state_topic: "cjb_1/switch_4"
    value_template: "{{ value_json.state }}"
    device_class: door

binary_sensor:
  - name: "Alcove Window"
    state_topic: "cjb_1/switch_5"
    value_template: "{{ value_json.state }}"
    device_class: window

binary_sensor:
  - name: "MBR Solarium Door"
    state_topic: "cjb_1/switch_6"
    value_template: "{{ value_json.state }}"
    device_class: door

binary_sensor:
  - name: "MBR Stairwell Window"
    state_topic: "cjb_1/switch_7"
    value_template: "{{ value_json.state }}"
    device_class: window

binary_sensor:
  - ame: "Front Door"
    state_topic: "cjb_1/switch_8"
    value_template: "{{ value_json.state }}"
    device_class: door

binary_sensor:
  - name: "Bath Window"
    state_topic: "cjb_1/switch_9"
    value_template: "{{ value_json.state }}"
    device_class: window

binary_sensor:
  - name: "Slider Door"
    state_topic: "cjb_1/switch_10"
    value_template: "{{ value_json.state }}"
    device_class: door

binary_sensor:
  - name: "Will's Window"
    state_topic: "cjb_1/switch_11"
    value_template: "{{ value_json.state }}"
    device_class: window

binary_sensor:
  - name: "Computer Room Window"
    state_topic: "cjb_1/switch_12"
    value_template: "{{ value_json.state }}"
    device_class: window

binary_sensor:
  - name: "Upper Deck Door"
    state_topic: "cjb_1/switch_13"
    value_template: "{{ value_json.state }}"
    device_class: door

binary_sensor:
  - name: "Car Door"
    state_topic: "cjb_1/switch_14"
    value_template: "{{ value_json.state }}"
    device_class: door

binary_sensor:
  - name: "Garage Window"
    state_topic: "cjb_1/switch_15"
    value_template: "{{ value_json.state }}"
    device_class: window

binary_sensor:
  - name: "Garage Door"
    state_topic: "cjb_1/switch_16"
    value_template: "{{ value_json.state }}"
    device_class: door
    
# Sensors
# class = window:   On means open, Off means closed
#         door:     On means open, Off means closed
#         motion:   On means motion detected, Off means no motion (clear)
#         moisture: On means moisture detected (wet), Off means no moisture (dry)
#         battery:  On means low, Off means normal

  # Weather prediction
#  - platform: yr
#    name: "Weather Forcast"

sensor:
  - name: "Hot Water Temp"
    state_topic: "Water_room/temp1"
    value_template: "{{ value_json.temperature }}"
    device_class: temperature
    unit_of_measurement: "°F"

sensor:
  - name: "Cold Water Temp"
    state_topic: "Water_room/temp2"
    value_template: "{{ value_json.temperature }}"
    device_class: temperature
    unit_of_measurement: "°F"

sensor:
  - name: "Water Room Humidity"
    state_topic: "Water_room/humidity"
    value_template: "{{ value_json.humidity }}"
    device_class: humidity
    unit_of_measurement: "%"

sensor:
  - name: "Washer Room Humidity"
    state_topic: "Washer_room/humidity"
    value_template: "{{ value_json.humidity }}"
    device_class: humidity
    unit_of_measurement: "%"

sensor:
  - name: "Dryer Exhaust Temp"
    state_topic: "Washer_room/temp1"
    value_template: "{{ value_json.temperature }}"
    device_class: temperature
    unit_of_measurement: "°F"

sensor:
  - name: "Dryer Temp"
    state_topic: "Washer_room/temp2"
    value_template: "{{ value_json.temperature }}"
    device_class: temperature
    unit_of_measurement: "°F"

sensor:
  - name: "Washer Room Pressure"
    state_topic: "Washer_room/pressure"
    value_template: "{{ value_json.pressure }}"
    device_class: pressure
    unit_of_measurement: "mBar"

sensor:
  - name: "Water Room Pressure"
    state_topic: "Water_room/pressure"
    value_template: "{{ value_json.pressure }}"
    device_class: pressure
    unit_of_measurement: "mBar"

#  bathroom fan sensors
sensor:
  - name: "Lower Bath Temp"
    state_topic: "lower_bath_fan/temperature"
    value_template: "{{ value_json.temperature }}"
    device_class: temperature
    unit_of_measurement: "°F"

sensor:
  - name: "Lower Bath Humidity"
    state_topic: "lower_bath_fan/humidity"
    value_template: "{{ value_json.humidity }}"
    device_class: humidity
    unit_of_measurement: "%"

sensor:
  - name: "Lower Bath Fan"
    state_topic: "lower_bath_fan/state"
    value_template: "{{ value_json.switch }}"
    
sensor:
  - name: "Master Bath Temp"
    state_topic: "mbr_bath_fan/temperature"
    value_template: "{{ value_json.temperature }}"
    device_class: temperature
    unit_of_measurement: "°F"

sensor:
  - name: "Master Bath Humidity"
    state_topic: "mbr_bath_fan/humidity"
    value_template: "{{ value_json.humidity }}"
    device_class: humidity
    unit_of_measurement: "%"

sensor:
  - name: "Master Bath Fan"
    state_topic: "mbr_bath_fan/state"
    value_template: '{{ value_json.switch }}'
    
# cjb_1 temp sensors...
sensor:
  - name: "Solarium Temp"
    state_topic: "cjb_1/temp_1"
    value_template: '{{ value_json.temperature }}'
    device_class: temperature
    unit_of_measurement: "°F"

sensor:
  - name: "Solarium Supply Temp"
    state_topic: "cjb_1/temp_2"
    value_template: '{{ value_json.temperature }}'
    device_class: temperature
    unit_of_measurement: "°F"

sensor:
  - name: "MBR High Temp"
    state_topic: "cjb_1/temp_3"
    value_template: '{{ value_json.temperature }}'
    device_class: temperature
    unit_of_measurement: "°F"

sensor:
  - name: "MBR Low Temp"
    state_topic: "cjb_1/temp_4"
    value_template: '{{ value_json.temperature }}'
    device_class: temperature
    unit_of_measurement: "°F"

sensor:
  - name: "Return Air Temp"
    state_topic: "cjb_1/temp_5"
    value_template: "{{ value_json.temperature }}"
    device_class: temperature
    unit_of_measurement: "°F"

sensor:
  - name: "MBR Collector Temp"
    state_topic: "cjb_1/temp_6"
    value_template: "{{ value_json.temperature }}"
    device_class: temperature
    unit_of_measurement: "°F"

sensor:
  - name: "Garage Temp"
    state_topic: "cjb_1/temp_7"
    value_template: "{{ value_json.temperature }}"
    device_class: temperature
    unit_of_measurement: "°F"

sensor:
  - name: "Pool Heater In Temp"
    state_topic: "cjb_1/temp_8"
    value_template: "{{ value_json.temperature }}"
    device_class: temperature
    unit_of_measurement: "°F"

sensor:
  - name: "Pool Heater Out Temp"
    state_topic: "cjb_1/temp_9"
    value_template: "{{ value_json.temperature }}"
    device_class: temperature
    unit_of_measurement: "°F"

sensor:
  - name: "Wire Closet Temp"
    state_topic: "cjb_1/temp_10"
    value_template: "{{ value_json.temperature }}"
    device_class: temperature
    unit_of_measurement: "°F"

eof

Got it - just a syntax problem.

I only need one ‘sensor type’ for each type of sensor (don’t need all the ‘switch:’ statements)

Most of my system just came up! :slight_smile:

    switch:
     -  unique_id: stairs_accent
        object_id: stairs_accent
        name: "Stairs Accent"
        icon: mdi:light
        command_topic: 'sonoff_1/switch'
        payload_on: '{"switch":"ON"}'
        payload_off: '{"switch":"OFF"}'
        state_topic: 'sonoff_1/status'
        state_on:  '{"switch":"ON"}'
        state_off: '{"switch":"OFF"}'
        qos: 2
        retain: true
        availability:
        - topic: "homeassistant/window/availability"
          payload_available: "online"
          payload_not_available: "offline"

     -  unique_id: living_room_lamp
        object_id: living_room_lamp
        name: "Living Room Lamp"
        icon: mdi:light
        command_topic: 'sonoff_2/switch'
        payload_on: '{"switch":"ON"}'
        payload_off: '{"switch":"OFF"}'
        state_topic: 'sonoff_2/status'
        state_on:  '{"switch":"ON"}'
        state_off: '{"switch":"OFF"}'
        qos: 2
        retain: true

     -  unique_id: kitchen_leds
        object_id: kitchen_leds

1 Like

Couple of questions:

  1. Why specify a value for object_id that is identical to what Home Assistant will produce anyway based on the value of name?

  2. The values for payload_on/payload_off are used for both receiving and transmitting. So why also include the state_on/state_off options?

  3. retain: true means the published command (not the received command) will be stored on the MQTT broker. When your tasmotized switch reboots (or merely drops/reconnects its Wi-Fi) it will immediately receive the stored command. Is that the behavior you want?

1 and 2 are because I’m struggling to figure out the syntax for this thing. I have had trouble working out exactly how to structure the yaml files this time around, it changed since my previous attempts to get it up and running and I haven’t found documentation to be sufficient to work it out.

re 3: no, that’s not the behavior I want. I want the browsers that attach to be updated with the last recorded values from the sensors & switches.

The options themselves haven’t changed, just the arrangement.

Given the values you’ve specified, you can safely remove object_id, state_on, state_off and retain.