Skip to content

Commit b5f3648

Browse files
authored
Merge pull request #15 from MrSleeps/dev
- Removed the sensors tankname_manualcolorsimulationenabled and tankname_manualdaytimesimulationenabled - Fixed Firmware / Software version bug - Bumped manifest.json version to 2.0.1
2 parents 28f271c + 5b0a90e commit b5f3648

File tree

5 files changed

+44
-17
lines changed

5 files changed

+44
-17
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,11 @@ These sensors are read only, if you want to do things like turn the aquarium lig
1818
* `tankname_white` (White light intensity, 0-100)
1919
* `tankname_current_profile` (Currently selected profile)
2020
* `tankname_profiles` (Count of available profiles)
21-
* `tankname_manualcolorsimulationenabled` **This will be removed in a future version**
22-
* `tankname_manualdaytimesimulationenabled` **This will be removed in a future version**
2321
* `tankname_device_time` (Time on the controller)
2422
* `tankname_tank_combined_sensor` (this combines all the above sensors into one)
2523

2624
## Other Entities/Devices
27-
* `select.tankname_profiles` (Allows you to choose a profile that the controller will use)
25+
* `select.tankname_profile` (Allows you to choose a profile that the controller will use)
2826
* `binary_sensor.tankname_manual_color_simulation_enabled` (Shows On/Off - used by the switch)
2927
* `binary_sensor.tankname_manual_daytime_simulation_enabled` (Shows On/Off - used by the switch)
3028
* `light.tankname_light` (The main light, allows you to control your tank light)
@@ -34,6 +32,8 @@ These sensors are read only, if you want to do things like turn the aquarium lig
3432
* `number.tank_name_manual_daytime_simulation_duration` (Sets the duration of the Manual Colour Simulation)
3533
* `Tank Device` (All sensors are linked to the relevant device)
3634

35+
(tank_name will be replaced with whatever you named your fish tank)
36+
3737

3838
## How to install
3939

@@ -59,6 +59,10 @@ Also, Home Assistants way of dealing with colours on the colour wheel doesn't pl
5959

6060
Any bugs you find, please post on GitHub (and provide logs!).
6161

62+
## Upgrade Notes
63+
64+
The sensors tankname_manualcolorsimulationenabled and tankname_manualdaytimesimulationenabled have been removed, you will need to manually remove them and update any scripts/automations to use the binary sensors instead.
65+
6266
## Bug Reports
6367
Please follow the template when submitting a bug report, to help logs will be needed. To turn on debug logging for the integration you will need to add something like the following to your configuration.yml
6468
```

custom_components/juwel_helialux/coordinator.py

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,21 @@ def __init__(self, hass, tank_host, tank_protocol, tank_name, update_interval):
3737

3838
async def async_config_entry_first_refresh(self):
3939
"""Fetch initial data and store device info."""
40-
await self.async_refresh() # ✅ Use async_refresh() instead of directly calling `_async_update_data`
41-
_LOGGER.debug("Device Info Initialized: %s", self.device_info)
40+
await self.async_refresh() # Fetch initial data
41+
42+
# Fetch device info from the Helialux controller
43+
_LOGGER.debug("Fetching device info from Helialux controller...")
44+
device_info = await self.helialux.device_info()
45+
_LOGGER.debug("Fetched device info: %s", device_info) # Log fetched info
46+
47+
if device_info:
48+
self.device_info["sw_version"] = device_info.get("firmware_version", "Unknown")
49+
self.device_info["hw_version"] = device_info.get("hardware_version", "Unknown")
50+
self.device_info["model"] = f"{device_info.get('device_type', 'Unknown')}"
51+
_LOGGER.debug("Updated Device Info: %s", self.device_info)
52+
else:
53+
_LOGGER.error("Failed to fetch device info from Helialux controller.")
54+
4255

4356
async def _async_update_data(self):
4457
"""Fetch the latest data from the Helialux device."""
@@ -59,7 +72,13 @@ async def _async_update_data(self):
5972
_LOGGER.error("Invalid profile data format from Helialux, received: %s", type(profile_data))
6073
profile_data = {}
6174

62-
_LOGGER.debug(f"Before updating HA: current_profile={self.data.get('current_profile', 'offline')}")
75+
# Fetch device info and update the device_info dictionary
76+
device_info = await self.helialux.device_info()
77+
if device_info:
78+
self.device_info["sw_version"] = device_info.get("firmware_version", "0.0.0.0")
79+
self.device_info["hw_version"] = device_info.get("hardware_version", "0.0.0.0")
80+
self.device_info["model"] = f"{device_info.get('device_type', 'Unknown')}"
81+
_LOGGER.debug("Updated Device Info: %s", self.device_info)
6382

6483
# Merge status and profile data
6584
merged_data = {
@@ -76,11 +95,13 @@ async def _async_update_data(self):
7695
}
7796

7897
_LOGGER.debug("Merged data: %s", merged_data)
79-
_LOGGER.debug(f"After updating HA: current_profile={merged_data.get('current_profile', 'offline')}")
80-
_LOGGER.debug(f"Raw statusvars.js profile: {status_data.get('currentProfile', 'offline')}")
81-
8298
return merged_data # ✅ Always return a dictionary
8399

84100
except Exception as e:
85101
_LOGGER.error("Error fetching data from Helialux device: %s", e)
86-
return {} # ✅ Always return an empty dictionary
102+
return {} # ✅ Always return an empty dictionary
103+
104+
async def async_update(self):
105+
"""Update the entity's state."""
106+
await self._async_update_data() # Call the data update method
107+
self.async_write_ha_state() # Notify Home Assistant to refresh the entity state

custom_components/juwel_helialux/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
"issue_tracker": "https://github.com/MrSleeps/Juwel-HeliaLux-Home-Assistant-Custom-Component/issues",
1111
"platforms": ["sensor", "light", "select", "binary_sensor"],
1212
"requirements": ["aiohttp"],
13-
"version": "2.0.0"
13+
"version": "2.0.1"
1414
}

custom_components/juwel_helialux/pyhelialux/pyHelialux.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,14 +197,18 @@ async def device_info(self):
197197
return {}
198198

199199
try:
200-
return {
201-
"device_type": parsed_devvars["info"][0] if len(parsed_devvars["info"]) > 0 else "Unknown",
202-
"hardware_version": parsed_devvars["info"][1] if len(parsed_devvars["info"]) > 1 else "Unknown",
203-
"firmware_version": parsed_devvars["info"][2] if len(parsed_devvars["info"]) > 2 else "Unknown",
200+
device_type = f"{parsed_devvars['info'][0]} {parsed_statusvars.get('lamp', 'Unknown')}"
201+
device_info = {
202+
# "device_type": parsed_devvars["info"][0] if len(parsed_devvars["info"]) > 0 else "Unknown",
203+
"device_type": device_type if len(parsed_devvars["info"]) > 0 else "Unknown",
204+
"hardware_version": parsed_devvars["info"][1].lstrip('V') if len(parsed_devvars["info"]) > 1 else "Unknown",
205+
"firmware_version": parsed_devvars["info"][2].lstrip('V') if len(parsed_devvars["info"]) > 2 else "Unknown",
204206
"ip_address": parsed_devvars["info"][3] if len(parsed_devvars["info"]) > 3 else "Unknown",
205207
"mac_address": parsed_devvars["info"][4] if len(parsed_devvars["info"]) > 4 else "Unknown",
206208
"light_channels": parsed_statusvars.get("lamp", "Unknown"),
207209
}
210+
_LOGGER.debug(f"Device info: {device_info}") # Debug log
211+
return device_info
208212
except KeyError as e:
209213
_LOGGER.error(f"Missing key in parsed data: {e}")
210214
return {}

custom_components/juwel_helialux/sensor.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,6 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
247247
JuwelHelialuxAttributeSensor(coordinator, tank_name, "blue", default_value=0, SensorStateClass=SensorStateClass.MEASUREMENT, unit="%"),
248248
JuwelHelialuxAttributeSensor(coordinator, tank_name, "green", default_value=0, SensorStateClass=SensorStateClass.MEASUREMENT, unit="%"),
249249
JuwelHelialuxAttributeSensor(coordinator, tank_name, "red", default_value=0, SensorStateClass=SensorStateClass.MEASUREMENT, unit="%"),
250-
JuwelHelialuxAttributeSensor(coordinator, tank_name, "manualColorSimulationEnabled", default_value=False),
251-
JuwelHelialuxAttributeSensor(coordinator, tank_name, "manualDaytimeSimulationEnabled", default_value=False),
252250
JuwelHelialuxAttributeSensor(coordinator, tank_name, "device_time", default_value="00:00"),
253251
]
254252

0 commit comments

Comments
 (0)