Repository navigation
Conversation
…gnostic categories
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds Home Assistant Long-Term Statistics (
state_class) support to operational sensors, introduces propane tankRemaining Fueland configurableEstimated Runtime Remainingsensors, exposes generatorError Code, Virtual Power Plant (VPP), and subscription billing dunning telemetry, and categorizes static/metadata entities underEntityCategory.DIAGNOSTIC.Motivation
run_time,protection_time,battery_voltage,exercise_minutes,outdoor_temperature,capacity,fuel_level,device_battery_level) lackedstate_class, preventing Home Assistant from recording Long-Term Statistics (LTS) for historical trends and outage analysis.eCodeLabel,enrolledInVpp,hasActiveVppEvent, andsubscription.isDunning, which were not surfaced as Home Assistant entities.EntityCategory.DIAGNOSTIC.Key Changes
custom_components/generac/const.py,config_flow.py,translations/{en,fr,nb,pt}.json):CONF_FUEL_BURN_RATE = "fuel_burn_rate"andDEFAULT_FUEL_BURN_RATE = 2.2(gal/h) toconst.pyandCONF_OPTIONS.GeneracOptionsFlowHandlerwith_option_schema(vol.All(vol.Coerce(float), vol.Range(min=0.0, min_included=False))forfuel_burn_rate),_option_defaultsanitization for invalid stored defaults, and defensiveMappingchecks onconfig_entry.options.fuel_burn_rateoption labels toen.json,fr.json,nb.json, andpt.json.custom_components/generac/sensor.py):SensorStateClass.TOTAL_INCREASINGonRunTimeSensorandProtectionTimeSensor.SensorStateClass.MEASUREMENTonBatteryVoltageSensor,ExerciseMinutesSensor,OutdoorTemperatureSensor,FuelLevelSensor, andDeviceBatteryLevelSensor.CapacitySensorwithSensorDeviceClass.VOLUME_STORAGE,UnitOfVolume.GALLONS,SensorStateClass.MEASUREMENT, and_safe_floatparsing.RemainingFuelSensor(remaining_fuel,gal,VOLUME_STORAGE,MEASUREMENT) andEstimatedRuntimeSensor(estimated_runtime,h,DURATION,MEASUREMENT) powered by_remaining_gallonsand_get_fuel_burn_rate(falling back safely to2.2when missing, non-mapping, or<= 0).ErrorCodeSensor(error_code) reading stripped non-emptyeCodeLabel._attr_entity_category = EntityCategory.DIAGNOSTICon 15 static/metadata sensors (DeviceTypeSensor,ActivationDateSensor,LastSeenSensor,ConnectionTimeSensor,SerialNumberSensor,ModelNumberSensor,DeviceSsidSensor,AddressSensor,DealerNameSensor,DealerEmailSensor,DealerPhoneSensor,PanelIDSensor,FuelTypeSensor,OrientationSensor,SignalStrengthSensor) while keeping operational sensors primary.custom_components/generac/binary_sensor.py):sensors(item: Item | None = None)(preserving no-arg backwards compatibility) andasync_setup_entry.GeneracVppEnrolledSensor(enrolled_in_vpp,EntityCategory.DIAGNOSTIC) andGeneracActiveVppEventSensor(active_vpp_event) for generators whenenrolledInVpporhasActiveVppEventis non-None.GeneracSubscriptionDunningSensor(subscription_dunning,BinarySensorDeviceClass.PROBLEM,EntityCategory.DIAGNOSTIC) whensubscriptionis non-None.README.md,tests/):README.md.tests/test_sensor.py,tests/test_binary_sensor.py,tests/test_config_flow.py, andtests/test_entity_registry.py(includinglen(classes) == 40, LTS attributes,EntityCategorychecks,fuel_burn_rateoverrides/fallbacks, VPP/subscription selection, and malformed payload edge cases).User Configuration / Migration Notes
unique_ids orentity_keys.state_classfor LTS andDiagnosticgrouping on metadata sensors on upgrade.fuel_burn_rate, default2.2) via Settings → Devices & services → Generac MobileLink → Configure.CapacitySensorandRemainingFuelSensoruseSensorDeviceClass.VOLUME_STORAGEwithUnitOfVolume.GALLONS, so Home Assistant displays values in the user's configured volume unit system (galorL).Test Plan
/Users/binarydev/Projects/ha-generac/.venv/bin/pytest --maxfail=3 --disable-warnings:143 passedacross all 13 test modules (test_api.py,test_auth.py,test_binary_sensor.py,test_config_flow.py,test_coordinator.py,test_diagnostics.py,test_entity.py,test_entity_registry.py,test_image.py,test_init.py,test_issues.py,test_sensor.py,test_weather.py)./opt/homebrew/bin/pre-commit run --all-files --show-diff-on-failure: all 8 hooks passed (check-added-large-files,check-yaml,end-of-file-fixer,trailing-whitespace,flake8,reorder-python-imports,black,prettier).manifest.jsonandtranslations/{en,fr,nb,pt}.json.