I don’t currently have an outside temperature/humidity sensor. I do have a fairly frequently updated weather service that provides me with what seem like accurate temperature and humidity values for my location. The temperature and humidity are in attributes of the weather sensor data.
I’ve found several posts telling me that the way to get this data out of an attribute is to create a new sensor with a state_attr()
function which gets the value from the attribute. The sensor definition is to be put into a configuration file.
So, I have done the following and placed it in the configuration.yaml
file. Then restarted HA.
# Loads default set of integrations. Do not remove.
default_config:
# Load frontend themes from the themes folder
frontend:
themes: !include_dir_merge_named themes
# Text to speech
tts:
- platform: google_translate
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
#SystemMonitor
# Example configuration.yaml entry with all entry types (delete/comment out as necessary)
sensor:
- platform: systemmonitor
resources:
- type: disk_use_percent
arg: /config
- type: memory_use_percent
template:
- sensor:
- name: "LEV temperature"
device_class: temperature
state_class: measurement
state: "{{ state_attr('weather.l_etang_la_ville', 'temperature') | float }}"
- name: "LEV humidity"
unit_of_measure: %
state_class: measurement
state: "{{ state_attr('weather.l_etang_la_ville', 'humidity') | float }}"
The SystmeMonitor section works fine - so I know I’m editing the right file.
I can tail the logfile (via docker) but I don’t see any log entries related to my new sensors, good or bad.
Am I putting this configuration in the right place? Is it well formatted? Am I missing something basic about how to work with HA configuration files? How can I double-check the attribute names are correct?
Sorry for all the questions, but I’m at the stage of using HA where I can see how much I don’t know!