Skip to content

Commit

Permalink
Merge pull request #538 from kylegordon/energy_monitoring
Browse files Browse the repository at this point in the history
Energy monitoring
  • Loading branch information
kylegordon committed Jun 19, 2024
2 parents 4b63e09 + ccd35c2 commit e36e049
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 2 deletions.
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

0 comments on commit e36e049

Please sign in to comment.