Skip to content

Commit

Permalink
Added signal strength sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
gazoodle committed Apr 12, 2022
1 parent c9fc8ca commit 1725c44
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,15 +327,13 @@ https://www.gnu.org/licenses/gpl-3.0.html
- Handle other device types such as Waterfall
- Handle inMix for lighting control
- Add API documentation
- RF signal strength for EN(Home) -> CO(Spa)
- Merge reminders branch from @kalinrow
- List property for User demands in pack classes
- List property for errors in pack classes
- Tidy up support files. One class per file
- Full sweep for typing hints - Ongoing
- Add sensor for errors
- Add switch for winterizing
- Add sensor for RF signal strength
- Add ability to set hours so we can implement a crude clock sync mechanism
- Think about a way to provide access to behaviour refresh frequencies so that
it can be customised
Expand All @@ -359,6 +357,7 @@ https://www.gnu.org/licenses/gpl-3.0.html
- Moved protocol retry constants to GeckoConfig class
- Added 2 second pause between protocol retries to allow intouch2 EN module to settle
- Increased default timeout from 2 to 4 seconds
- Added radio channel and signal strength sensor

## Done/Fixed in 0.4.5

Expand Down
4 changes: 4 additions & 0 deletions sample/cui.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ def make_display(self) -> None:
lines.append(f"{sensor}")
lines.append(f"{self.facade.eco_mode}")
lines.append(f"{self.ping_sensor}")
lines.append(f"{self.radio_sensor}")

else:

Expand All @@ -170,12 +171,14 @@ def make_display(self) -> None:
elif self.spa_state == GeckoSpaState.CONNECTED:
lines.append(f"{self.spa_name} connecting")
lines.append(f"{self.ping_sensor}")
lines.append(f"{self.radio_sensor}")
lines.append("")

elif self.spa_state == GeckoSpaState.ERROR_RF_FAULT:

lines.append(f"{self.spa_name} not ready")
lines.append(f"{self.ping_sensor}")
lines.append(f"{self.radio_sensor}")
lines.append("")
lines.append(
"Lost contact with your spa, it looks as if it is turned off"
Expand All @@ -185,6 +188,7 @@ def make_display(self) -> None:

lines.append(f"{self.spa_name} not ready")
lines.append(f"{self.ping_sensor}")
lines.append(f"{self.radio_sensor}")
lines.append("")
lines.append(
"Lost contact with your intouch2 module, please investigate"
Expand Down
33 changes: 33 additions & 0 deletions src/geckolib/async_spa_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,33 @@ def on_event(self, event: GeckoSpaEvent) -> None:
def __repr__(self):
return f"{self.name}: {self.state}"

class RadioConnectionSensor(GeckoAutomationBase):
"""Sensor with the current radio connection data"""

def __init__(self, spaman: GeckoAsyncSpaMan) -> None:
super().__init__(spaman.unique_id, "Radio", spaman.spa_name, "RADIO")
self.channel = spaman._spa.channel
self.signal = spaman._spa.signal
if self.signal > 100:
self.signal = 100

@property
def state(self):
"""The state of the sensor"""
return f"Channel {self.channel}, {self.signal}%"

@property
def unit_of_measurement(self):
"""The unit of measurement for the sensor, or None"""
return None

@property
def device_class(self):
return "string"

def __repr__(self):
return f"{self.name}: {self.state}"

def __init__(self, client_uuid: str, **kwargs: str) -> None:
"""Initialize a SpaMan class
Expand Down Expand Up @@ -161,6 +188,7 @@ def __init__(self, client_uuid: str, **kwargs: str) -> None:
self._status_sensor: Optional[GeckoAsyncSpaMan.StatusSensor] = None
self._reconnect_button: Optional[GeckoAsyncSpaMan.ReconnectButton] = None
self._ping_sensor: Optional[GeckoAsyncSpaMan.PingSensor] = None
self._radio_sensor: Optional[GeckoAsyncSpaMan.RadioConnectionSensor] = None

########################################################################
#
Expand Down Expand Up @@ -338,6 +366,10 @@ def spa_state(self) -> GeckoSpaState:
def status_sensor(self) -> Optional[GeckoAsyncSpaMan.StatusSensor]:
return self._status_sensor

@property
def radio_sensor(self) -> Optional[GeckoAsyncSpaMan.RadioConnectionSensor]:
return self._radio_sensor

@property
def reconnect_button(self) -> Optional[GeckoAsyncSpaMan.ReconnectButton]:
return self._reconnect_button
Expand Down Expand Up @@ -390,6 +422,7 @@ async def _handle_event(self, event: GeckoSpaEvent, **kwargs) -> None:

elif event == GeckoSpaEvent.CONNECTION_GOT_CHANNEL:
self._ping_sensor = GeckoAsyncSpaMan.PingSensor(self)
self._radio_sensor = GeckoAsyncSpaMan.RadioConnectionSensor(self)
await self._handle_event(GeckoSpaEvent.CLIENT_HAS_PING_SENSOR)

elif event == GeckoSpaEvent.CONNECTION_SPA_COMPLETE:
Expand Down

0 comments on commit 1725c44

Please sign in to comment.