-
-
Notifications
You must be signed in to change notification settings - Fork 29.2k
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
Changed update method to self.async_update_ha_state #18536
Conversation
@@ -75,7 +75,7 @@ | |||
if service.service == SERVICE_SELECT_CMODE: | |||
cmode = service.data.get(ATTR_CMODE) | |||
await device.select_cmode(cmode) | |||
await device.update() | |||
device.async_update_ha_state(force_refresh=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use device.async_schedule_update_ha_state
.
@@ -142,11 +142,13 @@ def supported_features(self): | |||
"""Turn on epson.""" | |||
from epson_projector.const import TURN_ON | |||
await self._projector.send_command(TURN_ON) | |||
self.async_update_ha_state(force_refresh=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't necessary since this is a polling entity. At the end of the service call a state update will be scheduled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So what could be wrong that without that it is switching on (for about 30 seconds) -> off (30 seconds) -> on?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you test all services?
|
||
async def async_turn_off(self): | ||
"""Turn off epson.""" | ||
from epson_projector.const import TURN_OFF | ||
await self._projector.send_command(TURN_OFF) | ||
self.async_update_ha_state(force_refresh=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above.
@@ -167,12 +169,14 @@ def volume_level(self): | |||
"""Set color mode in Epson.""" | |||
from epson_projector.const import (CMODE_LIST_SET) | |||
await self._projector.send_command(CMODE_LIST_SET[cmode]) | |||
self.async_update_ha_state(force_refresh=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above.
|
||
async def async_select_source(self, source): | ||
"""Select input source.""" | ||
from epson_projector.const import INV_SOURCES | ||
selected_source = INV_SOURCES[source] | ||
await self._projector.send_command(selected_source) | ||
self.async_update_ha_state(force_refresh=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above.
@@ -102,7 +102,7 @@ def __init__(self, websession, name, host, port, encryption): | |||
self._volume = None | |||
self._state = None | |||
|
|||
async def update(self): | |||
async def async_update(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before this change, since this method was named update
while being a coroutine, the method would never be executed. That's probably the reason for the behavior you've noticed.
#18357 is trying to fix the same problem. |
Ok, let's close this as other one is already merged. |
Description:
Changed device.update to device.async_update_ha_state(force_refresh=True) and invoke state update after:
If I don't invoke state updates than e.g. during turn_on it is switching to on in HA, than after some time it is switching to off and again after ~1 minute it is going on.
Checklist:
tox
. Your PR cannot be merged unless tests pass