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
36 changes: 21 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
> [!WARNING]
> This is an unofficial Generac MobileLink integration. Generac systems may change at anytime, which would break the functionality of this integration, and it should not be used for anything mission critical. If you would like an alternative for whole-home generators that allows you to drop the need to maintain a MobileLink subscription, please see the ongoing discussions [here](https://github.com/binarydev/ha-generac/issues/227) for local hardware solutions using GenMon and Raspberry Pi's. Shoutout to [Jeff Terrace](https://github.com/jterrace) for his [blog post](https://blog.jeffterrace.com/2025/10/free-from-generac-with-genmon.html) documenting how to set this up, so others can benefit from his experience!
>
> As of July 26, 2026, this integration currently support logging in with your MyGenerac/MobileLink username and password to expose your devices to Home Assistant for monitoring and automation.
> As of July 26, 2026, this integration currently supports logging in with your MyGenerac/MobileLink username and password to expose your devices to Home Assistant for monitoring and automation.

# Generac MobileLink/MyGenerac Home Assistant Integration

[![hacs][hacsbadge]][hacs]

**Custom Generac integration component with support for generators and propane tank monitors. It will set up the following platforms.**

| Platform | Entities created for each generator |
| --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `binary_sensor` | `is_connected`, `is_connecting`, `has_maintenance_alert`, `has_warning`, `missed_exercise`, plus conditional `enrolled_in_vpp`, `active_vpp_event`, `subscription_dunning` |
| `button` | `reset_service_timer`, `boost_polling` |
| `sensor` | `status`, `run_time`, `protection_time`, `activation_date`, `last_seen`, `connection_time`, `battery_voltage`, `device_type`, `dealer_email`, `dealer_name`, `dealer_phone`, `address`, `status_text`, `status_label`, `error_code`, `serial_number`, `model_number`, `device_ssid`, `panel_id`, `signal_strength`, `hours_until_service`, optional `exercise_minutes`, `outdoor_temperature`, `device_battery_level` |
| Platform | Entities created for each generator (by `entity_key`) |
| --------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `binary_sensor` | `is_connected`, `is_connecting`, `has_maintenance_alert`, `show_warning`, `missed_exercise`, plus conditional `enrolled_in_vpp`, `active_vpp_event`, `subscription_dunning` |
| `button` | `reset_service_timer`, `boost_polling` |
| `sensor` | `status`, `run_time`, `protection_time`, `activation_date`, `last_seen`, `connection_time`, `battery_voltage`, `device_type`, `dealer_email`, `dealer_name`, `dealer_phone`, `address`, `status_text`, `status_label`, `error_code`, `serial_number`, `model_number`, `device_ssid`, `panel_id`, `signal_strength`, `hours_until_service`, plus conditional `exercise_minutes`, `outdoor_temperature`, `device_battery_level` |
| `weather` | conditional `weather` |
| `image` | conditional `hero_image` |

| Platform | Entities created for each propane tank monitor |
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `binary_sensor` | `is_connected`, `is_connecting`, `has_maintenance_alert`, `has_warning`, plus conditional `subscription_dunning` |
| `sensor` | `status`, `capacity`, `fuel_level`, `remaining_fuel`, `estimated_runtime`, `fuel_type`, `orientation`, `last_reading_date`, `battery_level`, `address`, `device_type`, optional `signal_strength`, `device_battery_level`, `outdoor_temperature` |
| Platform | Entities created for each propane tank monitor (by `entity_key`) |
| --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `binary_sensor` | `is_connected`, `is_connecting`, `has_maintenance_alert`, `show_warning`, plus conditional `subscription_dunning` |
| `sensor` | `status`, `capacity`, `fuel_level`, `remaining_fuel`, `estimated_runtime`, `fuel_type`, `orientation`, `last_reading`, `battery_level`, `address`, `device_type`, plus conditional `signal_strength`, `device_battery_level`, `outdoor_temperature` |
| `weather` | conditional `weather` |
| `image` | conditional `hero_image` |

> _Note:_ The tables above list each entity's stable `entity_key` (unique ID suffix). On fresh installs, Home Assistant generates entity IDs from friendly display names (for example, `Outage Boost Poll` for `boost_polling` and `Reset Maintenance Timer` for `reset_service_timer`), while existing installs preserve their entity IDs across upgrades.

![example][exampleimg]

Expand Down Expand Up @@ -83,7 +89,7 @@ Fast polling activates automatically whenever any generator is **Running**, **Ex

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

- **Outage Boost Poll button (`button.<device>_outage_boost_poll`)**: Created for each generator; pressing it immediately refreshes data and enables boost polling for `30` minutes.
- **Outage Boost Poll button (`boost_polling`, default entity ID `button.<device>_outage_boost_poll`)**: Created for each generator; pressing it immediately refreshes data and enables boost polling for `30` minutes.
- **`generac.boost_polling` action (service)**: Switches loaded entries into boost polling and triggers an immediate refresh. Accepts optional `duration_minutes` (`1`–`120`, default `30`) and optional `entry_id` (targets all loaded Generac entries if omitted).

### Telemetry, Long-Term Statistics & Diagnostics
Expand All @@ -97,11 +103,11 @@ You can also trigger fast polling manually (for example, from an automation trig
Each generator automatically tracks exercise activity and maintenance runtime baselines using Home Assistant storage (persisting cleanly across restarts without reloading the integration):

- **Maintenance Service Timer**:
- `sensor.<generator>_hours_until_service` shows estimated runtime hours remaining until the configured service interval (default `100` hours, configurable via **Options** -> `service_interval_hours`; set to `0` to disable).
- `Hours Until Service` (`hours_until_service`, default entity ID `sensor.<generator>_hours_until_service`) shows estimated runtime hours remaining until the configured service interval (default `100` hours, configurable via **Options** -> `service_interval_hours`; set to `0` to disable).
- On first setup, the baseline initializes to the generator's current `run_time` to avoid false day-1 alarms.
- After completing maintenance (oil change, filter, etc.), press **Reset Maintenance Timer** (`button.<generator>_reset_maintenance_timer`) on the device page to reset the baseline to the current run hours and clear any timer-based Repairs issue immediately.
- After completing maintenance (oil change, filter, etc.), press **Reset Maintenance Timer** (`reset_service_timer`, default entity ID `button.<generator>_reset_maintenance_timer`) on the device page to reset the baseline to the current run hours and clear any timer-based Repairs issue immediately.
- **Exercise Readiness Tracking**:
- `binary_sensor.<generator>_missed_exercise` turns `on` if no `Running`/`Exercising` status or run-hour increase is observed within `exercise_interval_days` (default `16` days to cover weekly and biweekly schedules; set to `0` to disable).
- `Missed Exercise` (`missed_exercise`, default entity ID `binary_sensor.<generator>_missed_exercise`) turns `on` if no `Running`/`Exercising` status or run-hour increase is observed within `exercise_interval_days` (default `16` days to cover weekly and biweekly schedules; set to `0` to disable).
- **Proactive Home Assistant Repairs Alerts**:
- `low_battery_voltage`: raised when generator starting battery voltage drops below `low_battery_threshold` (default `12.2` V).
- `missed_exercise`: raised when the generator exceeds `exercise_interval_days` without observed activity.
Expand Down Expand Up @@ -131,7 +137,7 @@ Generac's sign-in sessions expire 90 days after you log in, no matter how often
>
> ## Fair Warning
>
> Status Quo in summer 2026: This is an unofficial Generac integration, which requires using undocumented APIs in order to access the data of your Generac devices using your username and password. This is because Generac has changed (once again) the authentication workflow to actively block third-party access. They also originally stated that Home Assistant users were overloading their API. We have since adjusted accordingly to adapt to the new authenatication method and reduced our default polling interval from every 30 seconds to every 120 seconds, to be a "good" user of the API and cut the volume of traffic to their servers by 75%. This polling interval can also be tuned to your needs in the options panel of the HA integration once you have set it up, as seen [here](./setup_instructions/options.png).
> Status Quo in summer 2026: This is an unofficial Generac integration, which requires using undocumented APIs in order to access the data of your Generac devices using your username and password. This is because Generac has changed (once again) the authentication workflow to actively block third-party access. They also originally stated that Home Assistant users were overloading their API. We have since adapted to the new authentication method and switched to adaptive polling—defaulting to every 900 seconds (15 minutes) while idle and 120 seconds (2 minutes) while a generator is active—to be a "good" user of the API and minimize traffic to their servers. Both polling intervals can be tuned to your needs in the options panel of the HA integration once you have set it up, as seen [here](./setup_instructions/options.png).
>
> This approach implies that when Generac is going to change something in their non-public/undocumented API, it's quite likely that the integration will break instantly.
>
Expand Down
71 changes: 48 additions & 23 deletions _test_local_access.py
Original file line number Diff line number Diff line change
@@ -1,48 +1,73 @@
# This script is a standalone test for the Generac API client.
# It logs in to the Generac API using credentials from environment variables
# and prints the device data in JSON format using a custom JSON encoder.
# Make sure to set the environment variables GENERAC_USER and GENERAC_PASS before running this script
# to avoid hardcoding sensitive information in the script.
# This script is intended to be run outside of Home Assistant, for testing purposes.
# It uses the aiohttp library for asynchronous HTTP requests and custom JSON encoding for dataclasses.
# Ensure you have aiohttp installed in your environment.
# If you're using Home Assistant, aiohttp is already included.
# You can install it using pip: pip install aiohttp
"""Standalone CLI helper to test GeneracAuth + GeneracApiClient outside HA.

Set GENERAC_USER and GENERAC_PASS in your environment before running:

GENERAC_USER="you@example.com" GENERAC_PASS="..." python _test_local_access.py
"""
import asyncio
import dataclasses
import json
import logging
import os
import sys

import aiohttp # type: ignore
from custom_components.generac.api import GeneracApiClient
from custom_components.generac.auth import GeneracAuth
from custom_components.generac.auth import InvalidMfaCodeError
from custom_components.generac.auth import MfaRequiredError

logging.basicConfig(level=logging.DEBUG)


# Your custom JSON encoder
class EnhancedJSONEncoder(json.JSONEncoder):
"""JSON encoder that serializes dataclasses."""

def default(self, o):
if dataclasses.is_dataclass(o):
return dataclasses.asdict(o)
return super().default(o)


# Async main logic
async def main():
jar = aiohttp.CookieJar(unsafe=True, quote_cookie=False)
async with aiohttp.ClientSession(cookie_jar=jar) as session:
api = GeneracApiClient(
session,
os.environ.get("GENERAC_USER", ""),
os.environ.get("GENERAC_PASS", ""),
os.environ.get("GENERAC_SESSION_COOKIE", ""),
async def _authenticate(
session: aiohttp.ClientSession, email: str, password: str
) -> GeneracAuth:
"""Authenticate via Auth0/DPoP, prompting on stdin if code-based MFA is required."""
try:
return await GeneracAuth.login(session, email, password)
except MfaRequiredError as exc:
flow = exc.flow
try:
while True:
code = input(f"Enter MFA code ({flow.mfa_type}): ").strip()
try:
return await flow.submit_mfa_code(code)
except InvalidMfaCodeError as err:
print(f"Invalid MFA code: {err}", file=sys.stderr)
except MfaRequiredError as next_exc:
flow = next_exc.flow
except BaseException:
await flow.aclose()
raise


async def main() -> None:
"""Sign in to Mobile Link and print fetched device payloads as JSON."""
email = os.environ.get("GENERAC_USER", "").strip()
password = os.environ.get("GENERAC_PASS", "")
if not email or not password:
print(
"Please set GENERAC_USER and GENERAC_PASS environment variables.",
file=sys.stderr,
)
await api.login()
sys.exit(1)

async with aiohttp.ClientSession() as session:
auth = await _authenticate(session, email, password)
api = GeneracApiClient(session, auth)
device_data = await api.get_device_data()
print(json.dumps(device_data, cls=EnhancedJSONEncoder))
print(json.dumps(device_data, cls=EnhancedJSONEncoder, indent=2))


# Run it using asyncio.run (preferred method in Python 3.7+)
if __name__ == "__main__":
asyncio.run(main())
2 changes: 1 addition & 1 deletion custom_components/generac/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
NAME = "generac"
DOMAIN = "generac"
DOMAIN_DATA = f"{DOMAIN}_data"
VERSION = "0.0.0"
VERSION = "0.6.1"

ATTRIBUTION = (
"Data provided by https://app.mobilelinkgen.com/api. "
Expand Down
2 changes: 1 addition & 1 deletion custom_components/generac/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
):
"""Setup binary_sensor platform."""
"""Set up image platform."""
coordinator: GeneracDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
data = coordinator.data
if isinstance(data, dict):
Expand Down
2 changes: 1 addition & 1 deletion custom_components/generac/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/binarydev/ha-generac/issues",
"requirements": ["dacite==1.9.2"],
"version": "0.6"
"version": "0.6.1"
}
4 changes: 2 additions & 2 deletions custom_components/generac/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
):
"""Setup binary_sensor platform."""
"""Set up sensor platform."""
coordinator: GeneracDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
data = coordinator.data
if isinstance(data, dict):
Expand Down Expand Up @@ -585,7 +585,7 @@ class FuelLevelSensor(GeneracEntity, SensorEntity):
entity_key = "fuel_level"

_attr_state_class = SensorStateClass.MEASUREMENT
device_class = SensorDeviceClass.BATTERY
_attr_icon = "mdi:propane-tank"
native_unit_of_measurement = PERCENTAGE

@property
Expand Down
Loading
Loading