Skip to content

Commit

Permalink
Improve island status
Browse files Browse the repository at this point in the history
  • Loading branch information
Bre77 committed Sep 16, 2024
1 parent dc7e9b5 commit 839b4fc
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 18 deletions.
14 changes: 3 additions & 11 deletions custom_components/teslemetry/manifest.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
{
"domain": "teslemetry",
"name": "Teslemetry",
"codeowners": [
"@Bre77"
],
"codeowners": ["@Bre77"],
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/teslemetry",
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/Teslemetry/hacs-teslemetry/issues",
"loggers": [
"tesla_fleet_api",
"teslemetry_stream"
],
"requirements": [
"tesla-fleet-api==0.7.4",
"teslemetry-stream==0.3.1"
],
"loggers": ["tesla_fleet_api", "teslemetry_stream"],
"requirements": ["tesla-fleet-api==0.7.6", "teslemetry-stream==0.3.1"],
"version": "2.0.6"
}
9 changes: 7 additions & 2 deletions custom_components/teslemetry/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
from homeassistant.util import dt as dt_util
from homeassistant.util.variance import ignore_variance

from .const import TeslemetryTimestamp, MODELS
from .const import TeslemetryIslandStates, TeslemetryTimestamp, MODELS
from .entity import (
TeslemetryEnergyInfoEntity,
TeslemetryEnergyLiveEntity,
Expand Down Expand Up @@ -75,6 +75,7 @@

ShiftStates = {"P": "p", "D": "d", "R": "r", "N": "n"}

IslandStates = ["on_grid","off_grid","off_grid_intentionally","island_status_unknown"]

@dataclass(frozen=True, kw_only=True)
class TeslemetrySensorEntityDescription(SensorEntityDescription):
Expand Down Expand Up @@ -1005,7 +1006,11 @@ class TeslemetryEnergySensorEntityDescription(SensorEntityDescription):
device_class=SensorDeviceClass.POWER,
entity_registry_enabled_default=False,
),
TeslemetryEnergySensorEntityDescription(key="island_status", device_class=SensorDeviceClass.ENUM),
TeslemetryEnergySensorEntityDescription(
key="island_status",
device_class=SensorDeviceClass.ENUM,
options=IslandStates
),
)


Expand Down
8 changes: 5 additions & 3 deletions custom_components/teslemetry/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,9 @@
"name": "Island status",
"state": {
"island_status_unknown": "Unknown",
"on_grid": "On grid"
"on_grid": "On grid",
"off_grid": "Off grid",
"off_grid_intentional": "Off grid intentionally"
}
},
"load_power": {
Expand Down Expand Up @@ -862,7 +864,7 @@
},
"title": "An active subscription is required"
},
"unauthorized missing scopes":{},
"unauthorized missing scopes": {},
"login_required": {}
},
"services": {
Expand Down Expand Up @@ -1039,4 +1041,4 @@
"name": "Set valet mode"
}
}
}
}
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ colorlog==6.8.2
homeassistant==2024.8.3
pip>=24.1.1,<24.3
ruff==0.6.5
tesla-fleet-api==0.7.4
teslemetry-stream==0.3.1
tesla-fleet-api==0.7.6
teslemetry-stream==0.3.1

0 comments on commit 839b4fc

Please sign in to comment.