Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use proper call for sensor updates #333

Merged
merged 3 commits into from
May 6, 2024
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
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"]

Check warning on line 67 in custom_components/openevse/__init__.py

View check run for this annotation

Codecov / codecov/patch

custom_components/openevse/__init__.py#L67

Added line #L67 was not covered by tests

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
Loading