Multiple sensors in yaml

Currently I have multiple sensors defined in my config file, each having their own section name (i.e. sensor 1, sensor 2, sensor 3, etc). I understand the recommended way to define sensors is to have them in a single section (i.e. sensor:) and then have each platform under the one section. YAML has specific requirements on how things are defined which I don’t fully understand. Would this be a valid entry?

sensor:
  - platform: wunderground
    api_key: xxxx
    monitored_conditions:
      - summary
      - temp_f
  - platform: speedtest
    minute:
    - 0
    - 30
    monitored_conditions:
      - ping
      - download

If anyone has an example of this, it would be greatly appreciated

After minute are the two values double-spaced such like:

minute:
  - 0
  - 30

You can test your configuration with

$ hass --script check_config

YAML is sensitive to indent.

Here is an example from my configuration.yaml

  sensor:

      - platform: mfi
        host: 192.168.1.XXX
        port: 6443
        username: Redacted
        password: Redacted
        ssl: true
        verify_ssl: false

      - platform: rest
        resource: http://192.168.1.XXX:1234/data_request?id=variableget&DeviceNum=20&serviceId=urn:micasaverde-com:serviceId:EnergyMetering1&Variable=Watts
        method: GET
        name: Power Line Watts

      - platform: template
        sensors:
          energy_meter:
            value_template: "{{ states.sensor.power_line_watts.state | round (0) | float * 0.001 | round (3) }}"
            friendly_name: Energy Meter
            unit_of_measurement: 'kW'
          meter_test:
            value_template: "{{ states('sensor.energy_meter') | float > 3.0 }}"

      - platform: glances
        name: Glances sensor
        host: 192.168.1.XXX
        port: 56578
        resources:
          - disk_use_percent
          - memory_use_percent
          - swap_use_percent
          - processor_load

      - platform: systemmonitor
        resources:
          - type: network_in
            arg: eth0
          - type: network_out
            arg: eth0
1 Like

I ran the test and here were the results:

Testing configuration at /home/pi/.homeassistant
16-09-21 10:37:36 WARNING (MainThread) [homeassistant.config] Found deprecated temperature unit in core config, expected unit system. Replace 'temperature_unit: °F' with 'unit_system: imperial'
16-09-21 10:37:36 INFO (MainThread) [requests.packages.urllib3.connectionpool] Starting new HTTP connection (1): maps.googleapis.com
16-09-21 10:37:36 WARNING (MainThread) [homeassistant.config] Incomplete core config. Auto detected elevation: 33
16-09-21 10:37:36 INFO (MainThread) [homeassistant.config] Upgrading config directory from 0.27.0 to 0.28.2

What’s interesting is I can’t find any reference to temperature_unit in my config. I also don’t see my sensors. Here is that section of my config:

## SENSORS ##
# Prediction of weather
sensor:
  - platform: wunderground
    api_key: xxxxxxx
    monitored_conditions:
      - weather
      - temp_f
      - feelslike_f
      - wind_mph
      - relative_humidity
      - precip_today_in

  - platform: speedtest 
    minute:
      - 0
      - 30    
    monitored_conditions:
      - ping 
      - download 
      - upload

That’s not a sensor parameter. It’s at the the top of your configuration.yaml file. It’s failing there

Ok… now I’m totally confused… when I run “hass --script check_config”, it checks the file at /home/pi/.homeassistant but my config is stored in /var/opt/homeassistant

@k5map

Change your unit_system: to imperial.
Also add a server_id: to you speedtest sensor.
I would remove your Wunderground api_key: from the post too unless it is fake.

PtP, thanks… I removed my key.

I’m not familiar with the server_id variable. Is it the same for all users or do I need to get a unique for my system?

You should choose one that is in your state. https://www.speedtest.net/speedtest-servers.php

Go to the website and press Ctrl+F to bring up a Find Search bar. Type the name of your City or a city near you. It will highlight the city. Use one of those IDs

Ok… I’m still trying to determine whether HA is using the config file in the .homeassistant or /var/opt directories but I’ve resolved my sensor problem

It should be /home/hass/.homeassistant

HASS always prints the config it is using during startup. You can specify the config directory for HASS (or scripts) by adding a -c /var/opt/homeassistant

For a full list of parameters try: hass --script check_config --help

@kellerza - I checked my log file and do not see any entry where HA list the configuration file it is using.

It is the first item printed to the console, but before the logger output is set.

So you will see it if you run it from the command line, like the check_config script or if you run sudo systemctl status [email protected] -l (that assumes systemd and that your service is called [email protected])