You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

227 lines
7.9 KiB

######################################################################
# @CCOSTAN - Follow Me on X
# For more info visit https://www.vcloudinfo.com/click-here
# Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig
# -------------------------------------------------------------------
# Phyn Plus Water Shutoff - Leak detection and auto shutoff
# Related Issue: 1550
# Push action buttons + Activity feed + Repairs issue while valve is closed.
# -------------------------------------------------------------------
# Info: https://www.vcloudinfo.com/2020/05/phyn-plus-smart-water-shutoff-device.html
# HACS: https://github.com/jordanruthe/homeassistant-phyn
# Product: https://amzn.to/2Zy3sbJ
# Notes: homeassistant-phyn v2026.6.3 exposes Phyn alerts as sensors/events.
# Notes: Production YAML uses alert sensors; event triggers require HA Labs enablement.
######################################################################
script:
phyn_send_actionable_leak_notification:
alias: "Phyn Send Actionable Leak Notification"
mode: parallel
fields:
source:
description: "Caller context for trace/debug visibility."
example: "initial"
sequence:
- service: script.notify_engine_two_button
data:
title: "Phyn Leak Detection"
value1: "Phyn is sensing a leak and turned off the water. Please verify."
who: "parents"
group: "Phyn"
title1: "Turn Water On"
action1: "PHYN_WATER_ON"
title2: "Snooze 30m"
action2: "SNOOZE_PHYN_NOTIFICATION"
icon1: "sfsymbols:arrow.up.circle"
icon2: "sfsymbols:clock"
level: "critical"
automation:
- alias: 'Phyn ShutOff Notification'
id: 78bbd270-ee1e-4b3d-80fd-44ce7c66dab5
mode: single
trigger:
- platform: state
entity_id: valve.phyn_shutoff_valve
to: 'closed'
id: valve_closed
- platform: state
entity_id:
- binary_sensor.phyn_leak_alert
- binary_sensor.phyn_offline_leak_shutoff_alert
- binary_sensor.phyn_recurring_flow_alert
- binary_sensor.phyn_pinhole_leak_alert
to: 'on'
id: leak_alert_sensor
condition:
- condition: state
entity_id: binary_sensor.phyn_leak_test_running
state: 'off'
variables:
alert_source: >-
{% if trigger.to_state is defined and trigger.to_state is not none %}
{{ trigger.to_state.name }}
{% else %}
Phyn leak alert
{% endif %}
valve_state: "{{ states('valve.phyn_shutoff_valve') }}"
action:
- choose:
- conditions:
- condition: template
value_template: "{{ trigger.id == 'leak_alert_sensor' }}"
sequence:
- service: script.send_to_logbook
data:
topic: "WATER"
message: >-
Phyn reported {{ alert_source }} while the shutoff valve is {{ valve_state }}.
Check water areas and the Phyn app.
- service: repairs.create
data:
issue_id: "phyn_leak_alert"
title: "Phyn leak-style alert"
severity: "warning"
persistent: true
description: >-
Phyn reported a leak-style alert through the Home Assistant integration.
alert_source: {{ alert_source }}
valve_state: {{ valve_state }}
Check the Phyn app, visible water areas, and the shutoff valve before deciding whether recovery action is needed.
- service: script.notify_engine
data:
title: "Phyn Leak Alert"
value1: >-
{{ alert_source }} is active. Check the Phyn app and water areas.
If the valve closed, use the shutoff notification to restore water after verification.
who: "parents"
group: "Phyn"
level: "time-sensitive"
default:
- service: script.send_to_logbook
data:
topic: "WATER"
message: "Phyn detected a leak and shut off the water. Please verify."
- service: repairs.create
data:
issue_id: "phyn_leak_shutoff"
title: "Phyn leak shutoff"
severity: "critical"
persistent: true
description: >-
Phyn detected a potential leak and automatically closed the main water valve.
Verify there are no active leaks before restoring water service.
- service: script.phyn_send_actionable_leak_notification
data:
source: "initial"
- service: persistent_notification.create
data:
title: '🚨 Phyn Leak Detection Alert'
message: |
**CRITICAL**: Phyn has detected a potential leak and automatically shut off the main water supply.
**Action Required**: Please verify there are no leaks in the house before turning the water back on.
**Time**: {{ now().strftime('%Y-%m-%d %H:%M:%S') }}
notification_id: 'phyn_leak_detection'
- alias: Dismiss Phyn Leak Alert When Alert Clears
id: 19ca32e0-58a9-44d7-aac0-67efd3421a98
description: Clear the warning-only Phyn alert repair after all leak-style alert sensors are off.
mode: single
trigger:
- platform: state
entity_id:
- binary_sensor.phyn_leak_alert
- binary_sensor.phyn_offline_leak_shutoff_alert
- binary_sensor.phyn_recurring_flow_alert
- binary_sensor.phyn_pinhole_leak_alert
to: 'off'
for: '00:02:00'
condition:
- condition: template
value_template: >-
{{ expand(
'binary_sensor.phyn_leak_alert',
'binary_sensor.phyn_offline_leak_shutoff_alert',
'binary_sensor.phyn_recurring_flow_alert',
'binary_sensor.phyn_pinhole_leak_alert'
) | selectattr('state', 'eq', 'on') | list | count == 0 }}
action:
- service: repairs.remove
continue_on_error: true
data:
issue_id: "phyn_leak_alert"
- service: script.send_to_logbook
data:
topic: "WATER"
message: "All Phyn leak-style alert sensors are clear. Warning repair removed."
- alias: Turn Phyn Water On
id: 1f295bb8-8925-4b22-PHYN-9fe079b295a8
trigger:
platform: event
event_type: mobile_app_notification_action
event_data:
action: PHYN_WATER_ON
action:
- service: valve.open_valve
target:
entity_id: valve.phyn_shutoff_valve
- service: script.notify_engine
data:
title: 'Phyn Leak Detection'
value1: 'Request Received. Attempting to Turn the Water back on.'
who: 'parents'
group: 'Phyn'
level: 'time-sensitive'
- service: script.speech_engine
data:
value1: >
I have been asked to Turn the House Water back on. Please verify there are no leaks in the house.
call_no_announcement: 1
- alias: Snooze Phyn Notification
id: 2f295bb8-8925-4b22-PHYN-9fe079b295a8
trigger:
platform: event
event_type: mobile_app_notification_action
event_data:
action: SNOOZE_PHYN_NOTIFICATION
action:
- delay: '00:30:00'
- service: script.phyn_send_actionable_leak_notification
data:
source: "snooze"
- alias: Dismiss Phyn Notification When Valve Opens
id: 3f295bb8-8925-4b22-PHYN-9fe079b295a8
trigger:
- platform: state
entity_id: valve.phyn_shutoff_valve
to: 'open'
action:
- service: repairs.remove
continue_on_error: true
data:
issue_id: "phyn_leak_shutoff"
- service: persistent_notification.dismiss
data:
notification_id: 'phyn_leak_detection'

Powered by TurnKey Linux.