Skip to content

Commit

Permalink
fix pre-released feature error
Browse files Browse the repository at this point in the history
  • Loading branch information
jkhalil committed Aug 23, 2023
1 parent 8d65e58 commit d0d7e8e
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 17 deletions.
13 changes: 9 additions & 4 deletions custom_components/eheim_digital/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@
],
}

DEVICE_MODES = {
"filter": FILTER_PUMP_MODES,
}

# Cansiter filter pump modes
FILTER_PUMP_MODES = {
"PM_NORMAL": 1,
Expand All @@ -84,3 +80,12 @@
"PM_CALIBRATION": 16384,
"PM_RESET": 32768,
}

# Heater modes
HEATER_MODES = {}

# LED Control modes
LED_CONTROL_MODES = {}

# pH Control modes
PH_CONTROL_MODES = {}
51 changes: 38 additions & 13 deletions custom_components/eheim_digital/devices.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
"""EHEIM Device representation."""
from .const import LOGGER, DEVICE_VERSIONS, DEVICE_GROUPS
from homeassistant.core import HomeAssistant
from homeassistant.components.input_select import DOMAIN as INPUT_SELECT_DOMAIN

from .const import (
LOGGER,
DEVICE_VERSIONS,
DEVICE_GROUPS,
FILTER_PUMP_MODES,
DEVICE_TYPES,
)

DEVICE_MODES = {
"filter": FILTER_PUMP_MODES,
# "heater": HEATER_MODES,
# "led_control": LED_CONTROL_MODES,
# "ph_control": PH_CONTROL_MODES,
}


class EheimDevice:
Expand Down Expand Up @@ -40,6 +56,27 @@ def __init__(self, data: dict) -> None:
)
LOGGER.debug("DEVICES: Initializing with data: %s", data)

async def create_input_select(self, hass: HomeAssistant):
"""Create an input_select for the device modes."""
# Get the modes for this device type
modes = DEVICE_MODES.get(self.device_type)
if not modes:
return # Exit if no modes found for this device type

# Get the icon for this device type
icon = DEVICE_TYPES.get(self.device_type, {}).get("icon", "mdi:help-circle")

# Define the service data
data = {
"name": f"{self.name} Mode",
"options": list(modes.keys()), # Use the mode options from the mapping
"initial": self.mode, # Set the initial mode
"icon": icon, # Use the icon from DEVICE_TYPES
}

# Call the input_select.create service
await hass.services.async_call(INPUT_SELECT_DOMAIN, "create", data)

@property
def name(self):
"""Return the name of the device."""
Expand Down Expand Up @@ -217,15 +254,3 @@ def update(self, data: dict) -> None:
if hasattr(self, attribute_name):
setattr(self, attribute_name, value)
LOGGER.debug("DEVICES: Updated EheimDevice %s: with data: %s", self.name, data)

async def create_input_select(self, hass):
"""Create an input_select for the device modes."""
# Define the service data
data = {
"name": f"{self.name} Mode",
"options": list(
FILTER_PUMP_MODES.keys()
), # Assuming these are the mode options
"initial": self.mode, # Set the initial mode
"icon": "mdi:filter", # You can use the icon from DEVICE_TYPES if desired
}

0 comments on commit d0d7e8e

Please sign in to comment.