Skip to content

Instantly share code, notes, and snippets.

@SirGoodenough
Last active December 13, 2024 17:31
Show Gist options
  • Save SirGoodenough/8451ff42f16aaa553578332efaf329af to your computer and use it in GitHub Desktop.
Save SirGoodenough/8451ff42f16aaa553578332efaf329af to your computer and use it in GitHub Desktop.
>>> Compensation Integration Yaml Code:
(See Home Assistant Docs Here: https://www.home-assistant.io/integrations/compensation/)
sprinkler_time:
unique_id: f7e5d58f-2fa6-49cd-ab12-feb95cb64490
source: sensor.gw2000b_v2_2_4_daily_rain_rate_piezo
# Ensure that the sensor's value will not have a state lower than -60.0
# when the source sensors value is less than 0.01
lower_limit: true
# Ensure that the sensor's value will not have a state greater than 0.0
# when the source sensors value is greater than .25
upper_limit: true
data_points:
- [0.01, -60.0]
- [0.25, 0.0]
>>> Automation to Capture time to water
- id: 5c0bad98-d196-4e24-8cad-bdfada255542
alias: Set Sprinkler Runtime
description: Get the compensation value from the data to set the runtime
trigger:
- platform: time
at: "23:59:59"
condition: []
action:
- service: input_number.set_value
metadata: {}
data:
value: "{{ comp_sensor }}"
target:
entity_id: input_number.sprinkler_time
variables:
comp_sensor: |-
{{
states.sensor.compensation_sensor_gw2000b_v2_2_4_daily_rain_rate_piezo.state
| float(5.01) | abs }}
mode: single
>>> Automation to do the Watering Before Sunrise
- id: a5895572-fc09-4fb9-b900-5535fcfa508a
alias: Water Garden Sprinkler
description: Turn on the sprinkler for set time
trigger:
- platform: sun
event: sunrise
offset: '-3600'
id: "Start watering 1 hour before sunrise"
condition:
- alias: "Watering while raining is worthless"
condition: state
entity_id: input_boolean.rain
state: 'off'
- alias: "Watering less than 5 minutes is worthless"
condition: template
value_template: "{{ run_mins > 5 }}"
action:
- type: turn_on
device_id: 620ac53c3380e0099889a87bdbce7421
entity_id: e713049e62ed5f30c705556bbc32ec9c
domain: switch
- alias: "Hold for the calculated time"
delay:
minutes: '{{ run_mins }}'
- type: turn_off
device_id: 620ac53c3380e0099889a87bdbce7421
entity_id: e713049e62ed5f30c705556bbc32ec9c
domain: switch
variables:
run_mins: '{{ states.input_number.sprinkler_time.state | float(4.01) }}'
mode: single
>>> Automation to Detect if it is Currently Raining
- id: 281d9138-d075-4d30-b359-ddaf80a3d6df
alias: Is it raining?
initial_state: true
description: "check the rain sensor to see if it's raining"
mode: single
trigger:
- platform: time_pattern
minutes: "/5"
id: Check every 5 minutes
condition: []
action:
- if:
- alias: Rain detected
condition: numeric_state
entity_id: sensor.gw2000b_v2_2_4_hourly_rain_rate_piezo
above: 0
then:
- alias: Toggle to on
service: input_boolean.turn_on
data:
entity_id: input_boolean.rain
else:
- alias: Toggle to off
service: input_boolean.turn_off
data:
entity_id: input_boolean.rain
mode: single
@SirGoodenough
Copy link
Author

More info about these in this You Tube Video: (Link TBT)

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