Skip to content

Commit

Permalink
Oops, disable polling for sensor entities instead of binary_sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
sebr committed Jan 14, 2020
1 parent b1d546a commit 528b09c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 22 deletions.
22 changes: 0 additions & 22 deletions custom_components/bhyve/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,25 +77,3 @@ def is_on(self):
"""Return the status of the sensor."""
return self._state is True

@property
def should_poll(self):
"""Disable polling."""
return False

async def async_update(self):
"""Retrieve latest state."""
self._ws_unprocessed_events[:] = [] # We don't care about these

try:
self._device = await self._bhyve.get_device(self._device_id)
if not device:
_LOGGER.info("No device found with id %s", self._device_id)
self._available = False
return

self._setup(self._device)

except BHyveError as err:
_LOGGER.warning("Failed to connect to BHyve servers. %s", err)
self._available = False

21 changes: 21 additions & 0 deletions custom_components/bhyve/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,24 @@ def icon(self):
)
return self._icon

@property
def should_poll(self):
"""Enable polling."""
return True

async def async_update(self):
"""Retrieve latest state."""
self._ws_unprocessed_events[:] = [] # We don't care about these

try:
self._device = await self._bhyve.get_device(self._device_id)
if not device:
_LOGGER.info("No device found with id %s", self._device_id)
self._available = False
return

self._setup(self._device)

except BHyveError as err:
_LOGGER.warning("Failed to connect to BHyve servers. %s", err)
self._available = False

0 comments on commit 528b09c

Please sign in to comment.