Skip to content

Commit

Permalink
fix oled displaying outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
pszafer committed Jan 17, 2025
1 parent 99af43c commit 243db34
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion boneio/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def __init__(
_name = _config.pop(ID)
restore_state = _config.pop(RESTORE_STATE, False)
_id = strip_accents(_name)
out = configure_relay(
out = configure_relay( #grouped_output updated here.
manager=self,
state_manager=self._state_manager,
topic_prefix=self._config_helper.topic_prefix,
Expand Down
11 changes: 7 additions & 4 deletions boneio/oled.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
setup_input,
)
from boneio.helper.events import EventBus, async_track_point_in_time, utcnow
from boneio.models import InputState, SensorState
from boneio.models import InputState, OutputState, SensorState

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -220,6 +220,8 @@ def render_display(self) -> None:
and self._current_screen in self._grouped_outputs
):
self._draw_output(data, draw)
for id in data.keys():
self._event_bus.add_event_listener(event_type="output", entity_id=id, listener_id=f"oled_{self._current_screen}", target=self._output_callback)
elif self._current_screen == UPTIME:
self._draw_uptime(data, draw)
self._event_bus.add_event_listener(event_type="host", entity_id=f"{self._current_screen}_hoststats", listener_id=f"oled_{self._current_screen}", target=self._standard_callback)
Expand All @@ -242,15 +244,16 @@ def render_display(self) -> None:
point_in_time=utcnow() + self._sleep_timeout.as_timedelta,
)

async def _output_callback(self, event: OutputState):
if self._grouped_outputs and self._current_screen in self._grouped_outputs:
self.handle_data_update(type=self._current_screen)

async def _standard_callback(self, event: SensorState):
self.handle_data_update(type=UPTIME)

async def _input_callback(self, event: InputState):
self.handle_data_update(type="inputs")

async def _output_callback(self, data):
self.handle_data_update(type="outputs")

def handle_data_update(self, type: str):
"""Callback to handle new data present into screen."""
if not self._current_screen:
Expand Down
2 changes: 1 addition & 1 deletion boneio/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# flake8: noqa
__version__ = "0.9.0dev14"
__version__ = "0.9.0dev15"

0 comments on commit 243db34

Please sign in to comment.