This guide assumes you already have a working and running Home Assistant server. If you don't, be sure to visit our Set up Home Assistant with a Raspberry Pi guide first.

Start out by logging in and opening up your Home Assistant dashboard and checking that the File editor is installed. 

As part of the setup, you should have an add-on either called configurator or File editor with a wrench icon next to it. Go ahead and select it.

If you don't see it, it may not be installed. You can find it under Settings → Add-ons Add-on Store File editor and go through the installation procedure.

If you already have it, but it's just not showing up, be sure it is started and the option to show in the sidebar is selected.

Click on the Folder Icon at the top and select configuration.yaml, then click on an area to the right of the file list to close it.

Add the following code to the bottom of the configuration file. Make sure the state_topic values match the value you used in the sensor code.

    - name: "Temperature"
      state_topic: "state/temp-sensor"
      unit_of_measurement: '°C'
      value_template: "{{ value_json.temperature }}"
    - name: "Humidity"
      state_topic: "state/temp-sensor"
      unit_of_measurement: '%'
      value_template: "{{ value_json.humidity }}"

Click the save button at the top.

From the Developer Tools menu, you can check that the configuration is valid and click on Restart to load the configuration changes you made. You can just click Quick reload to reload any changes you made.

Testing the Sensor

Click Overview at the top of the sidebar and you should see some icons at the top. Within those icons, there should be a temperature and humidity icon.

If you click on one of the icons, you can see a graph of how the value has changed over time. It will also show you how long it has been since the last update.


If you see the icons, but there is no data, it is easiest to start by checking the MQTT messages. We have a guide on how to use Desktop MQTT Client for, which can be used for the Home Assistant MQTT server as well.

Go ahead and configure a username and password to match your MQTT server and connect. Under subscribe, you can subscribe to the # topic to get all messages.

If you are seeing messages from the sensor, you may want to double check your Home Assistant configuration.

If you don't see any messages, you will want to follow the debugging section on the Code the Sensor page.

Going Further

You can easily modify the scripts to show additional information such as the battery level of the sensor or even change it to use other sensors. You can also hook up additional sensor and display that information as well.

This guide was first published on Feb 03, 2021. It was last updated on Sep 01, 2023.

This page (Home Assistant Configuration) was last updated on Sep 01, 2023.

Text editor powered by tinymce.