Skip to content
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
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ To stay gentle on Generac's rate-limited cloud API during normal standby while r
- **Idle polling interval (`scan_interval`)**: Default `900` seconds (15 minutes). Used when all devices are idle/ready.
- **Active polling interval (`active_scan_interval`)**: Default `120` seconds (2 minutes), capped at `min(scan_interval, active_scan_interval)` so fast polling never slows down a shorter idle interval.

Fast polling activates automatically whenever any generator is **Running**, **Exercising**, **Warning**, or **Stopped**, or when any device reports `isConnecting`, `showWarning`, or `isRunning`. After the fleet returns to idle, fast polling remains active for a `300`-second (5-minute) cooldown before returning to the idle interval.
Fast polling activates automatically whenever any generator is **Running**, **Exercising**, or **Warning**, or when any device reports `isConnecting`, `showWarning`, or `isRunning`. After the fleet returns to idle, fast polling remains active for a `300`-second (5-minute) cooldown before returning to the idle interval.

You can also trigger fast polling manually (for example, from an automation triggered by a utility power-loss sensor) using either:

Expand Down Expand Up @@ -112,9 +112,9 @@ Each generator automatically tracks exercise activity and maintenance runtime ba

When the integration sets up, three ready-to-use automation blueprints are automatically installed to `<config>/blueprints/automation/generac/`:

1. **Generac Outage Load Shedding** (`generac_outage_load_shedding.yaml`) — Sheds high-draw entities when status transitions to `Running` (ignoring `Exercising` cycles), waits for `Ready` stabilization, and optionally restores loads with a stagger delay.
2. **Generac Fault & Dealer Contact Alert** (`generac_fault_dealer_alert.yaml`) — Sends a notification populated with generator status, diagnostic `status_text`, and your preferred dealer's name and phone number on `Warning`, `Stopped`, `Communication Issue`, warning, or maintenance alerts.
3. **Generac Pre-Storm Readiness Digest** (`generac_storm_readiness_digest.yaml`) — Sends a readiness digest with status, connectivity, battery voltage, hours until service, and optional propane fuel level when a weather alert or trigger entity turns `on`.
1. **Generac Outage Load Shedding** (`generac_outage_load_shedding.yaml`) — Sheds high-draw entities when status transitions to `Running` (ignoring `Exercising` cycles), waits for `Ready` stabilization, and optionally restores previously active loads with a stagger delay.
2. **Generac Fault & Dealer Contact Alert** (`generac_fault_dealer_alert.yaml`) — Sends a notification populated with generator status, diagnostic `status_text`, optional `error_code`, and your preferred dealer's name and phone number on `Warning`, `Stopped`, `Communication Issue`, warning, or maintenance alerts.
3. **Generac Pre-Storm Readiness Digest** (`generac_storm_readiness_digest.yaml`) — Sends a readiness digest with status, connectivity, battery voltage, hours until service, and optional propane fuel level, remaining fuel, and estimated runtime when a weather alert or trigger entity turns `on`.

## Username + Password Authentication

Expand Down
29 changes: 27 additions & 2 deletions custom_components/generac/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ async def _async_handle_boost_polling(call: ServiceCall) -> None:
await coordinator.async_trigger_boost(duration_seconds)


def _enabled_platforms(entry: ConfigEntry) -> list[str]:
"""Return platforms enabled in entry options (all enabled by default)."""
options = entry_options(entry)
return [
platform
for platform in PLATFORMS
if (options.get(platform) if isinstance(options.get(platform), bool) else True)
]


def _reload_signature(entry: ConfigEntry) -> tuple[dict, dict]:
"""Snapshot of entry options and non-token data that require a reload on change."""
return (
Expand Down Expand Up @@ -175,7 +185,10 @@ async def _persist_relogin(fresh: GeneracAuth) -> None:

hass.data[DOMAIN][entry.entry_id] = coordinator

await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
enabled_platforms = _enabled_platforms(entry)
coordinator.loaded_platforms = list(enabled_platforms)
if enabled_platforms:
await hass.config_entries.async_forward_entry_setups(entry, enabled_platforms)
coordinator.reload_signature = _reload_signature(entry)
entry.async_on_unload(entry.add_update_listener(async_reload_entry))
if not hass.services.has_service(DOMAIN, SERVICE_BOOST_POLLING):
Expand All @@ -190,7 +203,19 @@ async def _persist_relogin(fresh: GeneracAuth) -> None:

async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Handle removal of an entry."""
unloaded = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
coordinator: GeneracDataUpdateCoordinator | None = hass.data.get(DOMAIN, {}).get(
entry.entry_id
)
platforms_to_unload = (
list(coordinator.loaded_platforms)
if isinstance(coordinator, GeneracDataUpdateCoordinator)
else _enabled_platforms(entry)
)
unloaded = (
await hass.config_entries.async_unload_platforms(entry, platforms_to_unload)
if platforms_to_unload
else True
)
if unloaded:
# Defensive default: if a previous reload already popped the
# coordinator (e.g. mid-reconfigure race), don't KeyError.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ blueprint:
name: Generac Fault & Dealer Contact Alert
description: >-
Send a detailed notification including generator status, diagnostic text,
and your preferred dealer's name and phone number when a fault, stop,
communication issue, warning, or maintenance alert occurs.
optional error code, and your preferred dealer's name and phone number when
a fault, stop, communication issue, warning, or maintenance alert occurs.
domain: automation
author: ha-generac
input:
Expand Down Expand Up @@ -49,6 +49,15 @@ blueprint:
filter:
- integration: generac
domain: sensor
error_code_sensor:
name: Generator Error Code Sensor (Optional)
description: Optional Generac error code sensor for active fault diagnostics.
default: null
selector:
entity:
filter:
- integration: generac
domain: sensor
notify_service:
name: Notification Service
description: >-
Expand Down Expand Up @@ -78,6 +87,7 @@ triggers:
variables:
status_entity: !input status_sensor
status_text_entity: !input status_text_sensor
error_code_entity: !input error_code_sensor
maintenance_entity: !input maintenance_sensor
dealer_name_entity: !input dealer_name_sensor
dealer_phone_entity: !input dealer_phone_sensor
Expand All @@ -87,19 +97,25 @@ actions:
action: !input notify_service
data:
title: >-
{% if trigger.entity_id == maintenance_entity %}
{%- if trigger.entity_id == maintenance_entity -%}
Generac Maintenance Alert ({{ states(status_entity) }})
{% else %}
{%- else -%}
Generac Alert: {{ states(status_entity) }}
{% endif %}
message: >-
{% set status = states(status_entity) %}
{% set details = states(status_text_entity) %}
{% set dealer = states(dealer_name_entity) %}
{% set phone = states(dealer_phone_entity) %}
{%- endif -%}
message: |-
{%- set status = states(status_entity) -%}
{%- set details = states(status_text_entity) -%}
{%- set dealer = states(dealer_name_entity) -%}
{%- set phone = states(dealer_phone_entity) -%}
Status: {{ status }}
{% if details not in ['unknown', 'unavailable', ''] %}
{%- if error_code_entity not in [none, ''] %}
{%- set error_code = states(error_code_entity) %}
{%- if error_code not in ['unknown', 'unavailable', ''] %}
Error Code: {{ error_code }}
{%- endif %}
{%- endif %}
{%- if details not in ['unknown', 'unavailable', ''] %}
Details: {{ details }}
{% endif %}
{%- endif %}
Dealer: {{ dealer if dealer not in ['unknown', 'unavailable', ''] else 'Not configured' }}
Phone: {{ phone if phone not in ['unknown', 'unavailable', ''] else 'Not configured' }}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ blueprint:
unit_of_measurement: seconds
restore_loads:
name: Restore Shed Loads
description: Turn shed entities back on after utility power stabilizes.
description: >-
Turn previously active shed entities (not already off, unavailable, or
unknown) back on after utility power stabilizes.
default: true
selector:
boolean: {}
Expand All @@ -53,7 +55,7 @@ blueprint:
max: 120
unit_of_measurement: seconds

mode: restart
mode: single
max_exceeded: silent

triggers:
Expand All @@ -62,28 +64,44 @@ triggers:
to: "Running"

variables:
shed_entities: !input shed_entities
restore_loads: !input restore_loads
restore_stagger_delay: !input restore_stagger_delay

actions:
- alias: Shed high-draw loads
action: homeassistant.turn_off
target:
entity_id: !input shed_entities
- alias: Wait for generator to return to Ready
wait_for_trigger:
- trigger: state
entity_id: !input generator_status
to: "Ready"
for:
seconds: !input ready_stabilization_delay
- variables:
shed_list: "{{ [shed_entities] if shed_entities is string else shed_entities }}"
entities_to_restore: >-
{{ shed_list | select('has_value') | reject('is_state', 'off') | list }}
- alias: Keep high-draw loads shed until generator stabilizes in Ready
repeat:
sequence:
- alias: Shed high-draw loads
action: homeassistant.turn_off
target:
entity_id: !input shed_entities
- alias: Wait for generator to stabilize in Ready or re-enter Running
wait_for_trigger:
- id: ready
trigger: state
entity_id: !input generator_status
to: "Ready"
for:
seconds: !input ready_stabilization_delay
- id: running_again
trigger: state
entity_id: !input generator_status
to: "Running"
until:
- condition: template
value_template: "{{ wait.trigger is not none and wait.trigger.id == 'ready' }}"
- if:
- condition: template
value_template: "{{ restore_loads }}"
value_template: "{{ restore_loads and (entities_to_restore | length > 0) }}"
then:
- alias: Restore shed loads
repeat:
for_each: !input shed_entities
for_each: "{{ entities_to_restore }}"
sequence:
- action: homeassistant.turn_on
target:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ blueprint:
description: >-
When a weather alert or storm readiness trigger turns on, send a summary of
your generator's readiness including status, connectivity, battery voltage,
hours until service, and optional propane tank fuel level.
hours until service, and optional propane tank fuel level, remaining fuel,
and estimated runtime.
domain: automation
author: ha-generac
input:
Expand Down Expand Up @@ -46,7 +47,25 @@ blueprint:
fuel_level_sensor:
name: Propane Fuel Level Sensor (Optional)
description: Optional Generac propane tank monitor fuel level sensor.
default: ""
default: null
selector:
entity:
filter:
- integration: generac
domain: sensor
remaining_fuel_sensor:
name: Remaining Propane Fuel Sensor (Optional)
description: Optional Generac propane tank remaining fuel sensor (gal).
default: null
selector:
entity:
filter:
- integration: generac
domain: sensor
estimated_runtime_sensor:
name: Estimated Runtime Remaining Sensor (Optional)
description: Optional Generac propane estimated runtime remaining sensor (h).
default: null
selector:
entity:
filter:
Expand Down Expand Up @@ -74,18 +93,35 @@ variables:
connected_entity: !input is_connected_sensor
service_entity: !input hours_until_service_sensor
fuel_entity: !input fuel_level_sensor
remaining_fuel_entity: !input remaining_fuel_sensor
estimated_runtime_entity: !input estimated_runtime_sensor

actions:
- alias: Send pre-storm generator readiness digest
action: !input notify_service
data:
title: "Generac Pre-Storm Readiness Digest"
message: >-
{% set connected = is_state(connected_entity, 'on') %}
message: |-
{%- set connected = is_state(connected_entity, 'on') -%}
Status: {{ states(status_entity) }}
Connected: {{ 'Online' if connected else 'Offline' }}
Battery Voltage: {{ states(battery_entity) }} V
Hours Until Service: {{ states(service_entity) }} h
{% if fuel_entity %}
Propane Fuel Level: {{ states(fuel_entity) }}%
{% endif %}
{%- if fuel_entity not in [none, ''] %}
{%- set fuel_level = states(fuel_entity) %}
{%- if fuel_level not in ['unknown', 'unavailable', ''] %}
Propane Fuel Level: {{ fuel_level }}%
{%- endif %}
{%- endif %}
{%- if remaining_fuel_entity not in [none, ''] %}
{%- set remaining_fuel = states(remaining_fuel_entity) %}
{%- if remaining_fuel not in ['unknown', 'unavailable', ''] %}
Remaining Fuel: {{ remaining_fuel }} gal
{%- endif %}
{%- endif %}
{%- if estimated_runtime_entity not in [none, ''] %}
{%- set estimated_runtime = states(estimated_runtime_entity) %}
{%- if estimated_runtime not in ['unknown', 'unavailable', ''] %}
Estimated Runtime: {{ estimated_runtime }} h
{%- endif %}
{%- endif %}
Loading
Loading