Skip to content

Commit

Permalink
fix: use proper call for sensor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
firstof9 committed May 6, 2024
1 parent a0d0d66 commit 332783f
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions custom_components/openevse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
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 @@ -44,20 +44,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

0 comments on commit 332783f

Please sign in to comment.