Skip to content

Commit

Permalink
fix: use proper call for sensor updates (#333)
Browse files Browse the repository at this point in the history
* fix: use proper call for sensor updates

* formatting

* update manifest.json
  • Loading branch information
firstof9 authored May 6, 2024
1 parent a0d0d66 commit 2ae59e3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
15 changes: 11 additions & 4 deletions custom_components/openevse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@
CONF_USERNAME,
EVENT_HOMEASSISTANT_STARTED,
)
from homeassistant.core import Config, CoreState, Event, HomeAssistant, State, callback
from homeassistant.core import (
Config,
CoreState,
Event,
EventStateChangedData,
HomeAssistant,
callback,
)
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers import device_registry as dr
from homeassistant.helpers.event import async_track_state_change_event
Expand Down Expand Up @@ -45,19 +52,19 @@
_LOGGER = logging.getLogger(__name__)


@callback
async def handle_state_change(
hass: HomeAssistant,
config_entry: ConfigEntry,
changed_entity: str, # pylint: disable-next=unused-argument
old_state: State, # pylint: disable-next=unused-argument
new_state: State,
event: Event[EventStateChangedData] | None = None,
) -> None:
"""Track state changes to sensor entities."""
manager = hass.data[DOMAIN][config_entry.entry_id][MANAGER]
invert = config_entry.data.get(CONF_INVERT)
grid_sensor = config_entry.data.get(CONF_GRID)
solar_sensor = config_entry.data.get(CONF_SOLAR)
voltage_sensor = config_entry.data.get(CONF_VOLTAGE)
changed_entity = event.data["entity_id"]

if grid_sensor is not None and changed_entity == grid_sensor:
grid = hass.states.get(grid_sensor).state
Expand Down
1 change: 1 addition & 0 deletions custom_components/openevse/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"import_executor": true,
"iot_class": "local_push",
"issue_tracker": "https://github.com/firstof9/openevse/issues",
"loggers": ["openevsehttp"],
"requirements": ["python-openevse-http==0.1.60"],
"version": "0.0.0-dev",
"zeroconf": ["_openevse._tcp.local."]
Expand Down

0 comments on commit 2ae59e3

Please sign in to comment.