Skip to content

Instantly share code, notes, and snippets.

@xbmcnut
Last active August 31, 2020 05:10
Show Gist options
  • Save xbmcnut/4d2245fbfd5973d2bb45a77e303d4c63 to your computer and use it in GitHub Desktop.
Save xbmcnut/4d2245fbfd5973d2bb45a77e303d4c63 to your computer and use it in GitHub Desktop.
Control my Hot Water element during peak power times.
# ###################################
# ## Automations
# ###################################
automation:
- alias: Turn off Hot Water Cylinder Mid-Week
id: 1d494c80-41eb-42eb-8e22-60a3606c29d9
trigger:
- platform: time
at: '00:01:00'
- platform: time
at: '07:00:00'
- platform: time
at: '17:00:00'
condition:
condition: time
weekday:
- mon
- tue
- wed
- thu
- fri
action:
- service: switch.turn_off
entity_id: switch.hot_water_cylinder_control
- alias: Turn on Hot Water Cylinder Mid-Week
id: c1d865ec-c6dd-4b2b-9a5f-5d6833977d3f
trigger:
- platform: time
at: '05:45:00'
- platform: time
at: '11:00:00'
- platform: time
at: '21:00:00'
condition:
condition: time
weekday:
- mon
- tue
- wed
- thu
- fri
action:
- service: switch.turn_on
entity_id: switch.hot_water_cylinder_control
- alias: 'HWC Heating On'
id: 59a99b3d-6f69-48ae-99c0-37fe9e4311e1
initial_state: true
trigger:
- platform: numeric_state
entity_id: sensor.hwc_shelly_power
above: 0.4
for:
seconds: 10
condition:
- condition: state
entity_id: input_boolean.hwc_element
state: 'off'
action:
- service: input_boolean.turn_on
entity_id: input_boolean.hwc_element
- alias: 'HWC Heating Off'
id: cbb4e38a-5638-46e1-8d56-57034606672d
initial_state: true
trigger:
- platform: numeric_state
entity_id: sensor.hwc_shelly_power
below: 0.4
for:
seconds: 10
condition:
- condition: state
entity_id: input_boolean.hwc_element
state: 'on'
action:
- service: input_boolean.turn_off
entity_id: input_boolean.hwc_element
input_boolean:
hwc_element:
name: Status - Off | On
initial: off
icon: mdi:water-boiler
binary_sensor:
- platform: mqtt
name: "HWC Shelly MQTT Status"
state_topic: "shellies/shelly1pm-76AE0C/online"
value_template: "{{ value }}"
payload_on: "true"
payload_off: "false"
device_class: connectivity
sensor:
- platform: template
sensors:
hwc_element_status:
friendly_name: "HWC Element Status"
value_template: "{% if states('sensor.hwc_shelly_power') | float > 0.4 %}Auto{% else %}Off{% endif %}"
# Reports 'on' time as a decimal #
- platform: history_stats
name: HWC Heating Today
entity_id: sensor.hwc_element_status
state: 'Auto'
type: time
start: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
end: '{{ now() }}'
# Converts above sensor from decimal to Hours and Minutes. Only used to UI #
- platform: template
sensors:
hwc_heating_time_on:
value_template: '{{ states.sensor.hwc_heating_today.attributes.value }}'
friendly_name: 'HWC Hours Heating'
@xbmcnut
Copy link
Author

xbmcnut commented Aug 31, 2020

My complete package above for control of my hot water cylinder. A Shelly1 controls a solid state relay that can handle 25 amps (mounted on a heatsink!). Prevents the cylinder from heating during peak power rates which is 0700-1100 and 1700-2100 Mon-Fri.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment