Skip to content

Instantly share code, notes, and snippets.

@danielolsson100
Created April 15, 2023 07:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielolsson100/3d43c48d127c84bc24c2e3e27de437d1 to your computer and use it in GitHub Desktop.
Save danielolsson100/3d43c48d127c84bc24c2e3e27de437d1 to your computer and use it in GitHub Desktop.
Home Assistant / Ferroamp / Tibber Pulse / Easee / EV - Calculated month price with Tibber price guarantee
# PoC code to calculate estimated Tibber month cost with Tibber EV charge price guarantee
# Requires Home Assistant and integration to Easee / Ferroamp / Tibber Pulse / Nordpool and some utility meters
# By adding these example entires to configuration.yaml
sensor:
- platform: template
sensors:
charge_cost_with_price_guarantee:
value_template: >-
{% set easee_cost_month = states('sensor.easee_cost_month') | float %}
{% set energy_cost_monthly = states('sensor.energy_cost_monthly') | float %}
{% set house_average_energy_price_month = states('sensor.house_average_energy_price_month') | float %}
{% set easee_average_energy_price_month = states('sensor.easee_average_energy_price_month') | float %}
{% set easee_energy_monthly = states('sensor.easee_energy_monthly') | float%}
{% set monthly_net_consumption_smedstorpsvagen_8 = states('sensor.monthly_net_consumption_smedstorpsvagen_8') | float %}
{% set monthly_cost_smedstorpsvagen_8 = states('sensor.monthly_cost_smedstorpsvagen_8') | float %}
{% set charge_kwh_cost_with_price_guarantee = house_average_energy_price_month/2 %}
{% set charge_cost_with_price_guarantee = ((house_average_energy_price_month/2) * easee_energy_monthly) | round(0) %}
{% set charge_cost_savings_with_price_guarantee = -1*(easee_cost_month - (house_average_energy_price_month/2) * easee_energy_monthly) | round(0) %}
{% set new_total_energy_cost_month = (monthly_cost_smedstorpsvagen_8 - easee_cost_month + ((house_average_energy_price_month/2) * easee_energy_monthly)) | round (0) %}
{{charge_cost_with_price_guarantee}}
friendly_name: 'Charge cost with price guarantee'
unit_of_measurement: 'SEK'
- platform: template
sensors:
charge_cost_savings_with_price_guarantee:
value_template: >-
{% set easee_cost_month = states('sensor.easee_cost_month') | float %}
{% set energy_cost_monthly = states('sensor.energy_cost_monthly') | float %}
{% set house_average_energy_price_month = states('sensor.house_average_energy_price_month') | float %}
{% set easee_average_energy_price_month = states('sensor.easee_average_energy_price_month') | float %}
{% set easee_energy_monthly = states('sensor.easee_energy_monthly') | float%}
{% set monthly_net_consumption_smedstorpsvagen_8 = states('sensor.monthly_net_consumption_smedstorpsvagen_8') | float %}
{% set monthly_cost_smedstorpsvagen_8 = states('sensor.monthly_cost_smedstorpsvagen_8') | float %}
{% set charge_kwh_cost_with_price_guarantee = house_average_energy_price_month/2 %}
{% set charge_cost_with_price_guarantee = ((house_average_energy_price_month/2) * easee_energy_monthly) | round(0) %}
{% set charge_cost_savings_with_price_guarantee = -1*(easee_cost_month - (house_average_energy_price_month/2) * easee_energy_monthly) | round(0) %}
{% set new_total_energy_cost_month = (monthly_cost_smedstorpsvagen_8 - easee_cost_month + ((house_average_energy_price_month/2) * easee_energy_monthly)) | round (0) %}
{{charge_cost_savings_with_price_guarantee}}
friendly_name: 'Charge cost savings with price guarantee'
unit_of_measurement: 'SEK'
- platform: template
sensors:
calculated_total_energy_cost_monthly:
value_template: >-
{% set easee_cost_month = states('sensor.easee_cost_month') | float %}
{% set energy_cost_monthly = states('sensor.energy_cost_monthly') | float %}
{% set energy_reward_monthly = states('sensor.energy_reward_monthly') | float %}
{% set house_average_energy_price_month = states('sensor.house_average_energy_price_month') | float %}
{% set easee_average_energy_price_month = states('sensor.easee_average_energy_price_month') | float %}
{% set easee_energy_monthly = states('sensor.easee_energy_monthly') | float%}
{% set monthly_net_consumption_smedstorpsvagen_8 = states('sensor.monthly_net_consumption_smedstorpsvagen_8') | float %}
{% set monthly_cost_smedstorpsvagen_8 = states('sensor.monthly_cost_smedstorpsvagen_8') | float %}
{% set charge_kwh_cost_with_price_guarantee = house_average_energy_price_month/2 %}
{% set charge_cost_with_price_guarantee = ((house_average_energy_price_month/2) * easee_energy_monthly) | round(0) %}
{% set charge_cost_savings_with_price_guarantee = -1*(easee_cost_month - (house_average_energy_price_month/2) * easee_energy_monthly) | round(0) %}
{% set new_total_energy_cost_month = (monthly_cost_smedstorpsvagen_8 - energy_reward_monthly - easee_cost_month + ((house_average_energy_price_month/2) * easee_energy_monthly)) | round (0) %}
{{new_total_energy_cost_month}}
friendly_name: 'Calculated total energy cost monthly'
unit_of_measurement: 'SEK'
utility_meter:
energy_cost_hourly:
source: sensor.monthly_cost_smedstorpsvagen_8
cycle: hourly
energy_cost_daily:
source: sensor.monthly_cost_smedstorpsvagen_8
cycle: daily
energy_cost_monthly:
source: sensor.monthly_cost_smedstorpsvagen_8
cycle: monthly
energy_cost_yearly:
source: sensor.monthly_cost_smedstorpsvagen_8
cycle: yearly
energy_reward_hourly:
source: sensor.accumulated_reward_smedstorpsvagen_8
cycle: hourly
energy_reward_daily:
source: sensor.accumulated_reward_smedstorpsvagen_8
cycle: daily
energy_reward_monthly:
source: sensor.accumulated_reward_smedstorpsvagen_8
cycle: monthly
energy_reward_yearly:
source: sensor.accumulated_reward_smedstorpsvagen_8
cycle: yearly
meter_energy_consumed_hourly:
source: sensor.last_meter_consumption_smedstorpsvagen_8
cycle: hourly
meter_energy_consumed_daily:
source: sensor.last_meter_consumption_smedstorpsvagen_8
cycle: daily
meter_energy_consumed_monthly:
source: sensor.last_meter_consumption_smedstorpsvagen_8
cycle: monthly
meter_energy_consumed_yearly:
source: sensor.last_meter_consumption_smedstorpsvagen_8
cycle: yearly
meter_energy_produced_hourly:
source: sensor.last_meter_production_smedstorpsvagen_8
cycle: hourly
meter_energy_produced_daily:
source: sensor.last_meter_production_smedstorpsvagen_8
cycle: daily
meter_energy_produced_monthly:
source: sensor.last_meter_production_smedstorpsvagen_8
cycle: monthly
meter_energy_produced_yearly:
source: sensor.last_meter_production_smedstorpsvagen_8
cycle: yearly
easee_energy_hourly:
source: sensor.easee_lifetime_energy
cycle: hourly
easee_energy_daily:
source: sensor.easee_lifetime_energy
cycle: daily
easee_energy_monthly:
source: sensor.easee_lifetime_energy
cycle: monthly
easee_energy_yearly:
source: sensor.easee_lifetime_energy
cycle: yearly
easee_cost_hourly:
source: sensor.easee_cost_year
cycle: hourly
easee_cost_daily:
source: sensor.easee_cost_year
cycle: daily
easee_cost_monthly:
source: sensor.easee_cost_year
cycle: monthly
easee_cost_yearly:
source: sensor.easee_cost_year
cycle: yearly
automation.yaml
alias: Easee - Set charging cost
description: ""
trigger:
- platform: state
entity_id:
- sensor.nordpool_kwh_se4_sek_2_10_025
condition:
- condition: or
conditions:
- condition: state
entity_id: sensor.easee_status
state: charging
- condition: state
entity_id: sensor.easee_status
state: awaiting_start
action:
- service: easee.set_charging_cost
data:
device_id: xxxxxxxxxxxxxxxxxxxxxxxxxxx
cost_per_kwh: "{{ (states('sensor.electricity_price_smedstorpsvagen_8')) | round (2) }}"
vat: 25
currency_id: SEK
mode: single
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment