MQTT Temperature Sensor

Tags: #<Tag:0x00007f73921fb460>

Ok, I give. I have dug into this as much as I feel I can, and I just can’t get it to work.

I’m running hassio as a virtual machine on my Synology box. I have many things working quite well, and feel I have an okay handle on things.

I’m trying to set up a Pi machine to monitor temperature and humidity, and send messages via MQTT that I can then monitor in HA. I’ve got MQTT running with other devices and believe I have a good understanding on how this all works.

So, I’ve got MQTT installed as an integration in HA. I can set up a listener in the ‘Configure’ option and see the messages coming through from the Pi. I’ve set up a MQTT sensor in my configuration as follows:

default_config:
  sensor:
    - platform: mqtt
      name: "Upstairs Temperature"
      entity_id: "environment.temperature.upstairs"
      state_topic: "homeassistant/test/front-door-pi"
      device_class: "temperature"
      qos: 0
      value_template: "{{ value_json.temperature_f }}"

Can someone tell me what I’m missing here? I’ve run out of ideas, and I’ve restarted HA countless times while messing with the configuration here. I’m not seeing this sensor show up as an entity no matter what I do. Thanks!

Your indentation is way off.

If, what you are showing is your configuration.yaml :

default_config:

sensor:
  - platform: mqtt
    name: "Upstairs Temperature"
    state_topic: "homeassistant/test/front-door-pi"
    device_class: "temperature"
    qos: 0
    value_template: "{{ value_json.temperature_f }}"

And you can’t have an entity-id in a mqtt sensor definition !

1 Like

Amazing. That works, and the linter in VS Code alerted me to the entity_id issue. I moved my configuration out from under default_config: and it is now working.

Maybe this is my issue - I assumed that everything must fall under default_config: - but I found that http: for instance shouldn’t be under it. What should / shouldn’t be under this node? Is this something I’ve misunderstood / misinterpreted here? I have many things underneath, such as mqtt, recorder etc… and they seem to work fine. Is this not correct? Is there documentation that I’ve likely missed on this one?

I appreciate your quick response. Thanks!!

Most domains need to be aligned totally left.


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

# Individual options represented by default_config
automation: !include automations.yaml
automation manual: !include_dir_merge_list automations
#cloud:
config:
frontend:
history:
input_boolean: !include input_boolean.yaml
input_datetime:
input_number: !include input_number.yaml
input_select:
input_text:
logbook:
#map:
#mobile_app:
person:
script: !include scripts.yaml
#ssdp:
sun:
system_health:
updater:
#zeroconf:
zone:

#includes not in default_config
python_script:
group: !include groups.yaml
sensor: !include sensor.yaml
binary_sensor: !include binary_sensor.yaml
switch: !include switch.yaml
light: !include light.yaml
timer: !include timer.yaml
scene: !include scenes.yaml
notify: !include notify.yaml

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

# Text to speech
tts:
  - platform: google_translate

homeassistant:
  name: Home
  customize: !include customize.yaml
  latitude: xx.8235615
  longitude: xx.1915097
  elevation: 16
  packages: !include_dir_named packages
#  customize_domain:
#    light:
#      assumed_state: false  

mqtt:
  broker: 10.0.0.63
  port: 1883
  discovery: true
  discovery_prefix: homeassistant
  username: xxx
  password: xxx
  birth_message:
    topic: 'hass/status'
    payload: 'online'
  will_message:
    topic: 'hass/status'
    payload: 'offline'  
    

  
recorder:
#  db_url: mysql://ha:[email protected]/hadb?charset=utf8
  db_url: sqlite:////share/hassio_db/home-assistant_v2.db  
  purge_keep_days: 3
  exclude:
    domains:
      - persistent_notification
      - automation
#      - weblink
      - updater
      - input_boolean
      - input_select
      - input_text
      - timer      
      - weather
      - scene
      - calendar
      - device_tracker
      - zone
    entities:
      - sun.sun # Don't record sun data  
      - binary_sensor.snapshots_stale
      - hangouts.conversations
      - binary_sensor.electricity2_button1
      - binary_sensor.ikea_button1_update_available
      - binary_sensor.ikeaoutlet1_update_available
      - binary_sensor.ikeaoutlet2_update_available
      - binary_sensor.ikeaoutlet3_update_available
      - binary_sensor.ikeaoutlet4_update_available
      - binary_sensor.ikeaoutlet5_update_available
      - binary_sensor.ikeapir2_update_available
      - binary_sensor.ikeapir_update_available
      - binary_sensor.ikeapirboven_update_available
      - binary_sensor.ikeapirkeuken_update_available
      - binary_sensor.updater
      - input_select.zigbee2mqtt_log_level
      - input_text.zigbee2mqtt_new_name
      - input_text.zigbee2mqtt_old_name
      - input_text.zigbee2mqtt_remove
      - sensor.zigbee2mqtt_version      
      - sensor.mains_apparent_power
      - sensor.mains_frequency
      - sensor.mains_power_factor
      - sensor.mains_reactive_power
      - sensor.upstairs_apparent_power
      - sensor.upstairs_frequency
      - sensor.upstairs_power_factor
      - sensor.upstairs_reactive_power
      - sensor.coordinator_version
      - binary_sensor.sonoffbasic3_button1
      - binary_sensor.electricity1_button1
      - binary_sensor.electricity2_button1
      - binary_sensor.electricity3_button1
      - binary_sensor.electricity4_button1
      - binary_sensor.electricity5_button1
      - binary_sensor.electricity6_button1
      - binary_sensor.coolcam1_button1
      - binary_sensor.coolcam2_button1
      - binary_sensor.coolcam3_button1
      - binary_sensor.coolcam4_button1
      - binary_sensor.coolcam5_button1
      - binary_sensor.coolcam6_button1
      - binary_sensor.coolcam7_button1
      - binary_sensor.pc_destiny
      - sensor.tunex_2f02_update_time
      - sensor.tunex_a202_update_time
      - sensor.tunex_4503_update_time
      - sensor.tunex_b002_update_time
      - sensor.tunex_4b01_update_time
      - sensor.tunex_4e01_update_time
#      - sensor.tunex_3201_update_time
      - sensor.alectov1_0048_update_time 
      - sensor.extern_ip
      - sensor.ophaalkalender_papier
      - sensor.ophaalkalender_pmd
      - sensor.ophaalkalender_restafval
      - weather.halluin
      - sensor.halluin_freeze_chance
      - sensor.halluin_next_rain
      - sensor.halluin_rain_chance
      - sensor.halluin_snow_chance
      - sensor.halluin_temperature
      - sensor.halluin_thunder_chance
      - sensor.halluin_uv
      - sensor.halluin_weather
      - sensor.halluin_weather_alert
      - sensor.halluin_wind_speed
      - sensor.ikeapirkeuken_requested_brightness_percent
      - sensor.ikeapirkeuken_requested_brightness_level
      - sensor.ikeapir2_requested_brightness_percent
      - sensor.ikeapir2_requested_brightness_level
      - sensor.ikeapirboven_requested_brightness_percent
      - sensor.ikeapirboven_requested_brightness_level
      - sensor.ikeapir_requested_brightness_percent
      - sensor.ikeapir_requested_brightness_level
      - sensor.CC2531_led 
      - sensor.CC2531_ant_led
      - sensor.CC2531router_led
      - sensor.coordinator_version
      - switch.zigbee2mqtt_main_join
      - sensor.xiron_1701_bat
      - sensor.xiron_2f02_bat
      - sensor.xiron_3201_bat
      - sensor.xiron_4503_bat
      - sensor.xiron_4b01_bat
      - sensor.time_online
      
      
  

logger:
  default: error
  logs:
#    homeassistant.helpers.script: info
    homeassistant.components.mqtt: error
    homeassistant.components.tuya: error
    homeassistant.components.light.rflink: debug
    homeassistant.components.sensor.rflink: error
    homeassistant.components.rflink.light: debug
    rflink: error
    rflink.light : debug



device_tracker:
  platform: nmap_tracker
  hosts:
    10.0.0.64
  home_interval: 10
 
google:
  client_id:xxx.apps.googleusercontent.com
  client_secret: xxx

http:
  ssl_certificate: /ssl/fullchain.pem
  ssl_key: /ssl/privkey.pem
  ip_ban_enabled: true
  login_attempts_threshold: 3
  
rflink:
  port: /dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0
#  host: 10.0.0.190
#  port: 7000
  wait_for_ack: false
  ignore_devices:
#    - aster_0ffc_01 
#    - aster_0ffc_02
#    - aster_00b8_02 
#    - aster_05e8*
#    - aster_0bd4*
#    - aster_085c*
    - aster_*
    - ev1527_012af3_02 
    - ev1527_01285a_02
    - ev1527_00252a*
    - halemeier*
    - blyss_th_*
    - doorbell_fe2a_1
    - legrandcad*
    - renkforcee*
    - fineoffset*
    - chuango_de8380_02
    - selectplus_07ffff_02
    - selectplus_00c677_02
    - ev1527_022f69*
    - eurodomest_2dd096*
    - eurodomest_0dd096*
    - eurodomest_2ed50c*
    - eurodomest_000001*
    - alectov*
    - keeloq*
    - ningbo64_*
    - tunex_6202*
    - tunex_e402*
    - elrodb*
    - eurodomest_000900*

hacs:
  token: xxx
#  python_script: true
  appdaemon: true
  
#rest_command:
#  reset_rflink:
#    url: 'http://10.0.0.190/reboot'
#    method: GET
  
google_assistant:
  project_id: home-assistant-xxx
  service_account: !include Home_assistant-xxx.json
  report_state: true
  exposed_domains:
    - light  
  expose_by_default: true


wake_on_lan:


#camera:
#  - platform: mjpeg
#    mjpeg_url: http://10.0.0.74:8081
#    name: pi_cam