All Projects → Limych → Ha Average

Limych / Ha Average

Licence: other
Average Sensor for Home Assistant

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Ha Average

Xiaomi miot raw
Universal Xiaomi MIoT integration for Home Assistant
Stars: ✭ 240 (+203.8%)
Mutual labels:  home-assistant, sensor
Calendarific
Calendarific holiday sensor for Home Assistant
Stars: ✭ 14 (-82.28%)
Mutual labels:  sensor, home-assistant
ha-iaquk
Indoor Air Quality Sensor Component for Home Assistant
Stars: ✭ 57 (-27.85%)
Mutual labels:  sensor, home-assistant
Nexus433
433MHz temperature and humidity sensor receiver that integrates with home automation systems.
Stars: ✭ 137 (+73.42%)
Mutual labels:  home-assistant, sensor
read your meter
Home Assistant sensor to read water meter
Stars: ✭ 27 (-65.82%)
Mutual labels:  sensor, home-assistant
Battery State Card
Battery state card for Home Assistant
Stars: ✭ 184 (+132.91%)
Mutual labels:  home-assistant, sensor
ha-gismeteo
Gismeteo Weather Provider for Home Assistant
Stars: ✭ 84 (+6.33%)
Mutual labels:  sensor, home-assistant
Home Assistant Config Fr
🏠Configuration de Home Assistant en français. 👨🏻‍💻 N'hésitez pas à ⭐ mon repo et à copier les bonnes idées ! 🇨🇵
Stars: ✭ 175 (+121.52%)
Mutual labels:  home-assistant, sensor
VisonicAlarm-for-Hassio
Visonic/Bentel/Tyco Alarm System integrtation for Home Assistant
Stars: ✭ 14 (-82.28%)
Mutual labels:  sensor, home-assistant
HADailySensor
Sensor for Home Assistant that gets reset at midnight
Stars: ✭ 20 (-74.68%)
Mutual labels:  sensor, home-assistant
Mini Graph Card
Minimalistic graph card for Home Assistant Lovelace UI
Stars: ✭ 1,370 (+1634.18%)
Mutual labels:  home-assistant, sensor
Home Assistant Config
🏠 Fully documented Home Assistant configuration for a smart-looking place. 😎 Be sure to ⭐️ my repo and copy ideas!
Stars: ✭ 258 (+226.58%)
Mutual labels:  home-assistant, sensor
uptime-card
Minimalistic uptime card for Home Assistant Lovelace UI
Stars: ✭ 152 (+92.41%)
Mutual labels:  sensor, home-assistant
Home-Assistant-custom-components-DPC-Alert
Italy Meteo-hydro alert and hydrogeological phenomena Civil Protection (Protezione Civile). In this custom component you can find the vigilance Bulletin and the Bulletin of national hydrogeological and hydraulic criticalities. They allow to check whether in your current location there will be criticalities/warnings related to weather-hydrogeolog…
Stars: ✭ 31 (-60.76%)
Mutual labels:  sensor, home-assistant
ical-sensor-homeassistant
an iCal Sensor for Home Assistant
Stars: ✭ 42 (-46.84%)
Mutual labels:  sensor, home-assistant
Pysmartnode
Micropython Smarthome framework
Stars: ✭ 58 (-26.58%)
Mutual labels:  home-assistant, sensor
Home Assistant Macbook Touch Bar
Displaying Home Assistant sensors in the Macbook Pro's touch bar using BTT 🤖💻
Stars: ✭ 64 (-18.99%)
Mutual labels:  home-assistant
Home Assistant Configs
Config files used for my install of Home Assistant. This is no longer maintained as I started my install over, and have been using the UI for configuration.
Stars: ✭ 73 (-7.59%)
Mutual labels:  home-assistant
Lovelace Time Picker Card
🕰️ Time Picker Card for Home Assistant's Lovelace UI
Stars: ✭ 63 (-20.25%)
Mutual labels:  home-assistant
Home Assistant Config
Home Assistant Configuration & Documentation for my Smart House.
Stars: ✭ 1,115 (+1311.39%)
Mutual labels:  home-assistant

Please ⭐️ this repo if you find it useful

Average Sensor for Home Assistant

GitHub Release GitHub Activity License

hacs Project Maintenance

Community Forum

This sensor allows you to calculate the average state for one or more sensors over a specified period. Or just the average current state for one or more sensors, if you do not need historical data.

Initially it was written special for calculating of average temperature, but now it can calculate average of any numerical data.

Example

What makes this sensor different from others built into HA:

Compare with the min-max sensor:
This sensor in the mean mode produces exactly the same average value from several sensors. But, unlike our sensor, it cannot receive the current temperature data from a weather, climate and water heater entities.

Compare with statistics sensor:
This sensor copes with the averaging of data over a certain period of time. However… 1) it cannot work with several sources at once (and can't receive temperature from weather, climate and water heater entities, like min-max sensor), 2) when calculating the average, it does not take into account how much time the temperature value was kept, 3) it has a limit on the number of values ​​it averages - if by chance there are more values, they will be dropped.

Note:
You can find a real example of using this component in my Home Assistant configuration.

I also suggest you visit the support topic on the community forum.

Breaking changes

  • Since version 1.3.0 the default sensor name is “Average” instead of “Average Temperature”

Known Limitations and Issues

  • Due to the fact that HA does not store in history the temperature units of measurement for weather, climate and water heater entities, the average sensor always assumes that their values ​​are specified in the same units that are now configured in HA globally.

Installation

Install from HACS (recommended)

  1. Have HACS installed, this will allow you to easily manage and track updates.
  2. Search for "Average".
  3. Click Install below the found integration.

... then if you want to use configuration.yaml to configure sensor...

  1. Add average sensor to your configuration.yaml file. See configuration examples below.
  2. Restart Home Assistant

Manual installation

  1. Using the tool of choice open the directory (folder) for your HA configuration (where you find configuration.yaml).
  2. If you do not have a custom_components directory (folder) there, you need to create it.
  3. In the custom_components directory (folder) create a new folder called average.
  4. Download file average.zip from the latest release section in this repository.
  5. Extract all files from this archive you downloaded in the directory (folder) you created.

... then if you want to use configuration.yaml to configure sensor...

  1. Add average sensor to your configuration.yaml file. See configuration examples below.
  2. Restart Home Assistant

Configuration Examples

To measure the average of current values from multiple sources:

# Example configuration.yaml entry
sensor:
  - platform: average
    name: 'Average Temperature'
    entities:
      - weather.gismeteo
      - sensor.owm_temperature
      - sensor.dark_sky_temperature

To measure the average of all values of a single source over a period:

# Example configuration.yaml entry
sensor:
  - platform: average
    name: 'Average Temperature'
    duration:
      days: 1
    entities:
      - sensor.gismeteo_temperature

or you can combine this variants for some reason.

* * *

I put a lot of work into making this repo and component available and updated to inspire and help others! I will be glad to receive thanks from you — it will give me new strength and add enthusiasm:


Patreon
or support via Bitcoin or Etherium:
Bitcoin
16yfCfz9dZ8y8yuSwBFVfiAa3CNYdMh7Ts

Configuration Variables

entities:
(list) (Required)
A list of temperature sensor entity IDs.

Note:
You can use weather provider, climate and water heater entities as a data source. For that entities sensor use values of current temperature.

Note:
You can use groups of entities as a data source. These groups will be automatically expanded to individual entities.

name:
(string) (Optional)
Name to use in the frontend.
Default value: "Average"

start:
(template) (Optional)
When to start the measure (timestamp or datetime).

end:
(template) (Optional)
When to stop the measure (timestamp or datetime).

duration:
(time) (Optional)
Duration of the measure.

precision:
(number) (Optional)
The number of decimals to use when rounding the sensor state.
Default value: 2

process_undef_as:
(number) (Optional)
Process undefined values (unavailable, sensor undefined, etc.) as specified value.

By default, undefined values are not included in the average calculation. Specifying this parameter allows you to calculate the average value taking into account the time intervals of the undefined sensor values.

Note:
This parameter does not affect the calculation of the count, min and max attributes.

Average Sensor Attributes

start:
Timestamp of the beginning of the calculation period (if period was set).

end:
Timestamp of the end of the calculation period (if period was set).

sources:
Total expanded list of source sensors.

count_sources:
Total count of source sensors.

available_sources:
Count of available source sensors (for current calculation period).

count:
Total count of processed values of source sensors.

min:
Minimum value of processed values of source sensors.

max:
Maximum value of processed values of source sensors.

Time periods

The average integration will execute a measure within a precise time period. You should provide none, only duration (when period ends at now) or exactly 2 of the following:

  • When the period starts (start variable)
  • When the period ends (end variable)
  • How long is the period (duration variable)

As start and end variables can be either datetimes or timestamps, you can configure almost any period you want.

Duration

The duration variable is used when the time period is fixed. Different syntaxes for the duration are supported, as shown below.

# 15 seconds
duration: 15
# 6 hours
duration: 06:00
# 1 minute, 30 seconds
duration: 00:01:30
# 2 hours and 30 minutes
duration:
  # supports seconds, minutes, hours, days
  hours: 2
  minutes: 30

* * *

I put a lot of work into making this repo and component available and updated to inspire and help others! I will be glad to receive thanks from you — it will give me new strength and add enthusiasm:


Patreon
or support via Bitcoin or Etherium:
Bitcoin
16yfCfz9dZ8y8yuSwBFVfiAa3CNYdMh7Ts

Examples

Here are some examples of periods you could work with, and what to write in your configuration.yaml:

Last 5 minutes: ends right now, last 5 minutes.

duration:
  minutes: 5

Today: starts at 00:00 of the current day and ends right now.

start: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
end: '{{ now() }}'

Yesterday: ends today at 00:00, lasts 24 hours.

end: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
duration:
  hours: 24

This morning (06:00–11:00): starts today at 6, lasts 5 hours.

start: '{{ now().replace(hour=6).replace(minute=0).replace(second=0) }}'
duration:
  hours: 5

Current week: starts last Monday at 00:00, ends right now.

Here, last Monday is today as a timestamp, minus 86400 times the current weekday (86400 is the number of seconds in one day, the weekday is 0 on Monday, 6 on Sunday).

start: '{{ as_timestamp( now().replace(hour=0).replace(minute=0).replace(second=0) ) - now().weekday() * 86400 }}'
end: '{{ now() }}'

Last 30 days: ends today at 00:00, lasts 30 days. Easy one.

end: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
duration:
  days: 30

All your history starts at timestamp = 0, and ends right now.

start: '{{ 0 }}'
end: '{{ now() }}'

Note:
The /dev-template page of your home-assistant UI can help you check if the values for start, end or duration are correct. If you want to check if your period is right, just click on your component, the start and end attributes will show the start and end of the period, nicely formatted.

Track updates

You can automatically track new versions of this component and update it by HACS.

Troubleshooting

To enable debug logs use this configuration:

# Example configuration.yaml entry
logger:
  default: info
  logs:
    custom_components.average: debug

... then restart HA.

Contributions are welcome!

This is an active open-source project. We are always open to people who want to use the code or contribute to it.

We have set up a separate document containing our contribution guidelines.

Thank you for being involved! 😍

Authors & contributors

The original setup of this component is by Andrey "Limych" Khrolenok.

For a full list of all authors and contributors, check the contributor's page.

License

creative commons Attribution-NonCommercial-ShareAlike 4.0 International License

See separate license file for full text.


Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].