Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Energy monitoring #538

Merged
merged 15 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions esphome/common/shelly_1_detached_push_button_common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ packages:
esphome:
name: ${device_name}
comment: ${device_description}
friendly_name: ${friendly_name}
platform: ESP8266
board: esp01_1m

Expand Down
118 changes: 118 additions & 0 deletions packages/givenergy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
---
sensor:
- platform: template
sensors:
battery_status:
friendly_name: "Battery status"
value_template: >
{%- set power_draw = states('sensor.battery_power') | int %}
{%- if power_draw < 0 %}
Charging
{%- elif power_draw == 0 %}
Balanced
{%- elif power_draw > 0 %}
Draining
{%- else -%}
Indeterminate
{%- endif %}
icon_template: >-
{%- set power_draw = states('sensor.battery_power') | int %}
{%- if power_draw < 0 %}
mdi:battery-charging
{%- elif power_draw > 0 %}
mdi:battery-minus
{%- else -%}
mdi:battery
{%- endif %}

grid_all:
friendly_name: "Grid Usage"
value_template: "{{ states('sensor.grid_export_power') | float + states('sensor.consumption_power') | float }}"
unit_of_measurement: 'W'

pv_all:
friendly_name: "PV Usage"
value_template: "{{ states('sensor.grid_export_power') | float + states('sensor.consumption_power') | float }}"
unit_of_measurement: 'W'

ashp_heating_cop:
unique_id: ashp_heating_cop
friendly_name: "ASHP Heating COP"
value_template: >
{%- set heat_generated = states('sensor.viewpoint_device_0_arotherm_plus_heat_generated_heating') | int %}
{%- set consumed_electricity = states('sensor.viewpoint_device_0_arotherm_plus_consumed_electrical_energy_heating') | int %}
{%- if heat_generated == unavailable or consumed_electricity == unavailable %}
unavailable
{%- elif heat_generated == unknown or consumed_electricity == unknown %}
unknown
{%- else %}
{{ heat_generated / consumed_electricity }}
{%- endif %}

ashp_hot_water_cop:
unique_id: ashp_hot_water_cop
friendly_name: "ASHP Hot Water COP"
value_template: >
{%- set heat_generated = states('sensor.viewpoint_device_0_arotherm_plus_heat_generated_domestic_hot_water') | int %}
{%- set consumed_electricity = states('sensor.viewpoint_device_0_arotherm_plus_consumed_electrical_energy_heating') | int %}
{%- if heat_generated == unavailable or consumed_electricity == unavailable %}
unavailable
{%- elif heat_generated == unknown or consumed_electricity == unknown %}
unknown
{%- else %}
{{ heat_generated / consumed_electricity }}
{%- endif %}

"{{ states('sensor.viewpoint_device_0_arotherm_plus_heat_generated_domestic_hot_water') | int / states('sensor.viewpoint_device_0_arotherm_plus_consumed_electrical_energy_domestic_hot_water') | int | float(default='NaN') }}"

- platform: integration
source: sensor.grid_all
method: left
name: grid_daily_usage
unit_prefix: k
round: 2

- platform: integration
source: sensor.pv_all
method: left
name: pv_daily_usage
unit_prefix: k
round: 2

# - platform: template
# #name: grid_all
# #friendly_name: "Grid Usage"
# value_template: "{{ states('sensor.grid_export_power') | float + states('sensor.consumption_power') | float }}"
# unit_of_measurement: 'W'

automation:
- alias: Boost hot water
id: boost_hot_water
trigger:
- platform: time
at: "11:00:00"
action:
- service: notify.mobile_app_nothing_phone_1
data:
title: "Waiting for sunshine and a full charge"
message: "When the battery is charged and we are exporting, we will trigger a hot water boost"
- wait_for_trigger:
- platform: numeric_state
entity_id: sensor.battery_percent
above: 99
for:
minutes: 30
- platform: numeric_state
entity_id: sensor.grid_export_power
above: 1000
for:
minutes: 30
timeout: "12:00:00"
continue_on_timeout: false
- service: switch.turn_on
target:
entity_id: switch.viewpoint_domestic_hot_water_0_boost
- service: notify.mobile_app_nothing_phone_1
data:
title: "Hot water boost triggered"
message: "Hot water boost triggered whilst the sun is shining"
2 changes: 1 addition & 1 deletion packages/kitchen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ light:
entities:
- light.kitchen_cabinets
- light.kitchen_worktop_lights
- light.kitchen
- light.kitchen_ceiling_lights

automation:
- alias: Kitchen motion
Expand Down
11 changes: 11 additions & 0 deletions packages/outside_lights.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ automation:
title: "Motion outside!"
message: >
Motion detected outside by {{ trigger.to_state.attributes.friendly_name }}
data:
clickAction: "/lovelace/outside"
url: "/lovelace/outside"


- alias: "Outside night lights on"
id: outside_night_lights_on
Expand Down Expand Up @@ -139,6 +143,13 @@ automation:
message: >
Motion detected outside by {{ trigger.to_state.attributes.friendly_name }}
Turning on outside lights
data:
clickAction: "/lovelace/outside"
url: "/lovelace/outside"

- service: homeassistant.turn_on
entity_id:
- group.outside_lights
# If this evaluates to false, the action will stop here.
- condition: template
value_template: "{{ not is_state('binary_sensor.home_occupied') }}"
Expand Down
2 changes: 1 addition & 1 deletion recorder.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
db_url: !secret db_url
purge_keep_days: 30
purge_keep_days: 21
exclude:
domains:
- automation
Expand Down
Loading