Sensor for average temperature

Folks,
I do have some sensors,
fibaro and two climate sensor where the temp is a attribute. All three do report result. What I wanna do now, is create an average templete sension which is calculating the average temp. But you imagine my try does not work

  average_kueche_temp:
      friendly_name: 'Average Kuechen Temp'
      unit_of_measurement: "°C"
      value_template: >-
          {{ (float(states.sensor.fibaro_kueche_temperature.state) + float(states.climate.kuche_thermostat_tepemerature.state) + float(states.climate.kuche_wandthermostat_temperature.state)) / 3 | round(2) }}

can anybody help me with the syntax?

You might want to play with this the template work area in hass its one of the icons at the bottom of the menu. THen you can past this code in and mess around with it until you get something that works. I tried it with my temp sensors and this worked. Putting () around the addition and division calculation seem to do the trick

{{ ((float(states.sensor.family_room_thermostat_temperature.state) + float(states.sensor.garage.state) + float(states.sensor.playroom.state))/3) | round(2) }}

You could look here … and use mean :slight_smile:

works like a charm. Can anybody help how I can get more than one min/max sensor. Created a minmax.yaml with:

platform: min_max
sensors:
  waerme:
# type: min, max or mean
  type: mean
  entity_ids:
  - sensor.fibaro_buero_temperature
  - sensor.fibaro_gang_temperature
  - sensor.fibaro_wohnzimmer_temperature
  - sensor.fibaro_kueche_temperature
  - sensor.fibaro_schlafzimmer_temperature
  - sensor.vision_multisensor_bad_temperature
  wohnzimmer_waerme:
# type: min, max or mean
  type: mean
  entity_ids:
  - sensor.fibaro_wohnzimmer_temperature
  - sensor.wohnzimmer_thermostat_temp_rechts
  - sensor.wohnzimmer_thermostat_temp_links
  - sensor.wohnzimmer_wand_temp
  buero_waerme:
# type: min, max or mean
  type: mean
  entity_ids:
  - sensor.fibaro_buero_temperature
  - sensor.buero_wand_temp
  - sensor.buero_thermostat_temp
  kueche_waerme:
# type: min, max or mean
  type: mean
  entity_ids:
  - sensor.fibaro_kueche_temperature
  bad_waerme:
# type: min, max or mean
  type: mean
  entity_ids:
  - sensor.vision_multisensor_bad_temperature
  - sensor.bad_wand_temp
  - sensor.bad_thermostat_temp
  schlafzimmer_waerme:
# type: min, max or mean
  type: mean
  entity_ids:
  - sensor.fibaro_schlafzimmer_temperature
  - sensor.schlafzimmer_wand_temp
  - sensor.schlafzimmer_thermostat_temp
  gang_waerme:
# type: min, max or mean
  type: mean
  entity_ids:
  - sensor.fibaro_gang_temperature

all I got @ startup:

Oct 31 22:29:01 home-assistant hass[5509]: 2017-10-31 22:29:01 ERROR (Thread-2) [homeassistant.util.yaml] YAML file /home/homeassistant/.homeassistant/sensor/min_max.yaml contains duplicate key "type". Check lines 4 and 14.
Oct 31 22:29:01 home-assistant hass[5509]: 2017-10-31 22:29:01 ERROR (Thread-2) [homeassistant.util.yaml] YAML file /home/homeassistant/.homeassistant/sensor/min_max.yaml contains duplicate key "entity_ids". Check lines 5 and 15.
Oct 31 22:29:01 home-assistant hass[5509]: 2017-10-31 22:29:01 ERROR (Thread-2) [homeassistant.util.yaml] YAML file /home/homeassistant/.homeassistant/sensor/min_max.yaml contains duplicate key "type". Check lines 14 and 22.
Oct 31 22:29:01 home-assistant hass[5509]: 2017-10-31 22:29:01 ERROR (Thread-2) [homeassistant.util.yaml] YAML file /home/homeassistant/.homeassistant/sensor/min_max.yaml contains duplicate key "entity_ids". Check lines 15 and 23.
Oct 31 22:29:01 home-assistant hass[5509]: 2017-10-31 22:29:01 ERROR (Thread-2) [homeassistant.util.yaml] YAML file /home/homeassistant/.homeassistant/sensor/min_max.yaml contains duplicate key "type". Check lines 22 and 29.
Oct 31 22:29:01 home-assistant hass[5509]: 2017-10-31 22:29:01 ERROR (Thread-2) [homeassistant.util.yaml] YAML file /home/homeassistant/.homeassistant/sensor/min_max.yaml contains duplicate key "entity_ids". Check lines 23 and 30.
Oct 31 22:29:01 home-assistant hass[5509]: 2017-10-31 22:29:01 ERROR (Thread-2) [homeassistant.util.yaml] YAML file /home/homeassistant/.homeassistant/sensor/min_max.yaml contains duplicate key "type". Check lines 29 and 34.
Oct 31 22:29:02 home-assistant hass[5509]: 2017-10-31 22:29:01 ERROR (Thread-2) [homeassistant.util.yaml] YAML file /home/homeassistant/.homeassistant/sensor/min_max.yaml contains duplicate key "entity_ids". Check lines 30 and 35.
Oct 31 22:29:02 home-assistant hass[5509]: 2017-10-31 22:29:01 ERROR (Thread-2) [homeassistant.util.yaml] YAML file /home/homeassistant/.homeassistant/sensor/min_max.yaml contains duplicate key "type". Check lines 34 and 41.
Oct 31 22:29:02 home-assistant hass[5509]: 2017-10-31 22:29:01 ERROR (Thread-2) [homeassistant.util.yaml] YAML file /home/homeassistant/.homeassistant/sensor/min_max.yaml contains duplicate key "entity_ids". Check lines 35 and 42.
Oct 31 22:29:02 home-assistant hass[5509]: 2017-10-31 22:29:01 ERROR (Thread-2) [homeassistant.util.yaml] YAML file /home/homeassistant/.homeassistant/sensor/min_max.yaml contains duplicate key "type". Check lines 41 and 48.
Oct 31 22:29:02 home-assistant hass[5509]: 2017-10-31 22:29:01 ERROR (Thread-2) [homeassistant.util.yaml] YAML file /home/homeassistant/.homeassistant/sensor/min_max.yaml contains duplicate key "entity_ids". Check lines 42 and 49.
Oct

How can I create more than one minmax sensor in my yaml file?

I do it like this…

- platform: min_max
  entity_ids:
    - sensor.miflora_bird_of_paradise_temperature
    - sensor.miflora_flowering_fern_temperature
    - sensor.miflora_volcano_fern_temperature
  name: avglroomtemp
  type: mean

- platform: min_max
  entity_ids:
    - sensor.miflora_bird_of_paradise_light_intensity
    - sensor.miflora_flowering_fern_light_intensity
    - sensor.miflora_volcano_fern_light_intensity
  name: avglroomlux
  type: mean

Hope that helps :slight_smile:

How would i copy that into a seperate min-max.yaml?

Well I just use copy and paste into notepad++ on my pc and save it, notepad++ saves it to my pi via winscp.

I run everything here on my MAC and use ATOM. No tabs …

what I can enter and ist working in my min-max.yaml is

platform: min_max
entity_ids:
    - sensor.fibaro_buero_temperature
    - sensor.fibaro_gang_temperature
name: avglroomtemp
type: mean

configuration.yaml has a

sensor: !include_dir_list sensor

things are great. As soon as I enhance it with a second sensor:

platform: min_max
entity_ids:
    - sensor.fibaro_buero_temperature
    - sensor.fibaro_gang_temperature
name: sensor123
type: mean
platform: min_max
entity_ids:
    - sensor.fibaro_buero_temperature
    - sensor.fibaro_gang_temperature
name: sensor456
type: mean

`hass --script check_config`
is claiming:


hass --script check_config
Testing configuration at /home/homeassistant/.homeassistant
2017-11-09 20:05:55 ERROR (Thread-2) [homeassistant.util.yaml] YAML file /home/homeassistant/.homeassistant/sensor/min-max.yaml contains duplicate key "platform". Check lines 0 and 6.
2017-11-09 20:05:55 ERROR (Thread-2) [homeassistant.util.yaml] YAML file /home/homeassistant/.homeassistant/sensor/min-max.yaml contains duplicate key "entity_ids". Check lines 1 and 7.
2017-11-09 20:05:55 ERROR (Thread-2) [homeassistant.util.yaml] YAML file /home/homeassistant/.homeassistant/sensor/min-max.yaml contains duplicate key "name". Check lines 4 and 10.
2017-11-09 20:05:55 ERROR (Thread-2) [homeassistant.util.yaml] YAML file /home/homeassistant/.homeassistant/sensor/min-max.yaml contains duplicate key "type". Check lines 5 and 11.

when I do a

platform: min_max
sensors:
  platform: min_max
  entity_ids:
    - sensor.fibaro_buero_temperature
    - sensor.fibaro_gang_temperature
  name: sensor123
  type: mean
platform: min_max
sensors:
  platform: min_max
  entity_ids:
    - sensor.fibaro_buero_temperature
    - sensor.fibaro_gang_temperature
  name: sensor
  type: mean 

 hass --script check_config
Testing configuration at /home/homeassistant/.homeassistant
2017-11-09 20:08:15 ERROR (Thread-2) [homeassistant.util.yaml] YAML file /home/homeassistant/.homeassistant/sensor/min-max.yaml contains duplicate key "platform". Check lines 0 and 8.
2017-11-09 20:08:15 ERROR (Thread-2) [homeassistant.util.yaml] YAML file /home/homeassistant/.homeassistant/sensor/min-max.yaml contains duplicate key "sensors". Check lines 1 and 9.

when I enter the following into min-max.yaml

platform: min_max
sensors:
  entity_ids:
    - sensor.fibaro_buero_temperature
    - sensor.fibaro_gang_temperature
  name: sensor123
  type: mean
sensors:
  entity_ids:
    - sensor.fibaro_buero_temperature
    - sensor.fibaro_gang_temperature
  name: sensor456
  type: mean

2017-11-09 20:09:46 ERROR (MainThread) [homeassistant.config] Invalid config for [sensor.min_max]: required key not provided @ data['entity_ids']. Got None. (See ?, line ?). Please check the docs at https://home-assistant.io/components/sensor.min_max/

when I added into min-max.yaml

platform: min_max
sensors:
  sensor123:
    entity_ids:
      - sensor.fibaro_buero_temperature
      - sensor.fibaro_gang_temperature
    name: sensor123
    type: mean
  sensor345:
    entity_ids:
      - sensor.fibaro_buero_temperature
      - sensor.fibaro_gang_temperature
    name: sensor456
    type: mean


hass --script check_config
Testing configuration at /home/homeassistant/.homeassistant
2017-11-09 20:12:57 INFO (MainThread) [homeassistant.setup] Setting up mqtt
2017-11-09 20:12:57 INFO (MainThread) [homeassistant.setup] Setup of domain mqtt took 0.0 seconds.
2017-11-09 20:12:57 INFO (MainThread) [homeassistant.setup] Setting up http
2017-11-09 20:12:57 INFO (MainThread) [homeassistant.setup] Setting up recorder
2017-11-09 20:12:57 INFO (MainThread) [homeassistant.setup] Setup of domain http took 0.0 seconds.
2017-11-09 20:12:57 INFO (MainThread) [homeassistant.setup] Setup of domain recorder took 0.0 seconds.
2017-11-09 20:12:57 INFO (MainThread) [homeassistant.setup] Setting up websocket_api
2017-11-09 20:12:57 INFO (MainThread) [homeassistant.setup] Setting up api
2017-11-09 20:12:57 INFO (MainThread) [homeassistant.setup] Setting up history
2017-11-09 20:12:57 INFO (MainThread) [homeassistant.setup] Setup of domain websocket_api took 0.0 seconds.
2017-11-09 20:12:57 INFO (MainThread) [homeassistant.setup] Setup of domain api took 0.0 seconds.
2017-11-09 20:12:57 INFO (MainThread) [homeassistant.setup] Setup of domain history took 0.0 seconds.
2017-11-09 20:12:57 INFO (MainThread) [homeassistant.setup] Setting up frontend
2017-11-09 20:12:57 INFO (MainThread) [homeassistant.setup] Setup of domain frontend took 0.0 seconds.
2017-11-09 20:12:57 ERROR (MainThread) [homeassistant.config] Invalid config for [sensor.min_max]: required key not provided @ data['entity_ids']. Got None. (See ?, line ?). Please check the docs at https://home-assistant.io/components/sensor.min_max/

Seems to work when I create per min-max sensor a new yaml and save it into my sensor directory.

From the docs …

It is important to note that each file must contain only one entry when using !include_dir_list.

created for each minmax sensor a seperate yaml and not works fine thanks

you could use one file and list each item:

- platform: min_max
  sensors:
    platform: min_max
    entity_ids:
    - sensor.fibaro_buero_temperature
    - sensor.fibaro_gang_temperature
    name: sensor123
    type: mean
- platform: min_max
  sensors:
    platform: min_max
    entity_ids:
      - sensor.fibaro_buero_temperature
      - sensor.fibaro_gang_temperature
    name: sensor
    type: mean

is there a way to actually know which is the sensor that has the highest or lowest temperature? so you can list the temperature and where?