Skip to content

epaulsen/ha-costsensor

Repository files navigation

Cost sensor

GitHub Release GitHub Activity License

hacs BuyMeCoffee

Community Forum

Creates a new platform to track cost of individual sensors.

This integration will set up the following platforms.

Platform Description
cost Tracks cost for a sensor based on a tariff.

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 cost.
  4. Download all the files from the custom_components/cost/ directory (folder) in this repository.
  5. Place the files you downloaded in the new directory (folder) you created.
  6. Restart Home Assistant
  7. Add a new sensor to your yaml config, see examples and schema below.

Sensor schema

Name Type Default Since Description
name string required v0.0.1 Name of sensor
source entity required v0.0.1 Increasing sensor, for example energy sensor
tariff entity required v0.0.1 Sensor for cost per unit of source sensor
unit_of_measurement string required v0.0.1 Output unit of measurement for this sensor
cron string optional v0.0.1 How often sensor resets. Allowed values are hourly, daily, weekly, monthly or yearly.

If cron does not have any value, the sensor will never reset it's value, and can that way be used to keep track of lifetime costs.

Example:

  - platform: cost
    source: sensor.your_energy_sensor_here_kwh
    tariff: sensor.power_cost_usd_kwh
    name: "Cost of something per hour"
    unit_of_measurement: "USD"
    cron: hourly

The above yaml will create a new sensor that will track cost for sensor given in source. Source sensor should be a sensor that increases it's value over time, for example an energy sensor(kWh, m^3 and so on). The cost sensor is calculated based on delta values for the source sensor multiplied with the tariff sensor. Tariff sensor input is a sensor that tracks cost per unit of source sensor, for example electricity cost per kWh.

Caution The platform entity does no validation of sensor types and units, you are responsible for ensuring that the tariff sensors unit_of_measurement matches the delta values produced by the source sensor.

Contributions are welcome!

If you want to contribute to this please read the Contribution guidelines


About

"cost" platform for Home-Assistant

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published