Open apbarratt opened 10 months ago
Great idea! I will try to get it wrapped up as much as possible into a skeleton today and upload it.
I just pushed a very early skeleton of the integration. It shows up in HA, can be configured with a mac address and has basic stuff. The next step I will try is to get a bidirectional communication with the LED going
Excellent :) I'm afraid my winter break is over but I'll try and contribute if I find time, though it's new territory for me I'm afraid.
Can confirm it installs using HACS and I can add a device using the mac address the fluval app shows when connecting itself.
We should add some basic regex checker to ensure the input only takes valid Mac addresses. I wonder if all of Fluval's kit starts with 44:A6:E5 (apparently a range belonging to "thinking technology" in china), if they do, then we could possibly even get away with forcing this starting point with a "not a recognised Fluval mac address" message.
I did some updates (commit comming asap):
So registering numbers works for now - even though they don't do anything yet and are not connected to the fluval led yet. But also first time that I got a real connection going:
About detecting fluval devices: I'm not sure that can be done. I think we found 2 different MAC starting byte sequences in the other thread, also there is "manufacturer data" contained in the BLE advertisement packets. But Fluval is using off the shelf microcontrollers without any real "fluval specific" identification to them. So we would detect any device using those microcontrollers als fluval lights then.
The service-uuids seems to be quite unique though, and we might be able to use "auto discovery" for those service uuids at a later stage. For now I would be completely happy with manual mac entry until I manage to get the numbers etc. wired to the device ;)
Curious, I'm not seeing any entities on mine even after that update. I wonder if it's not playing nice with the esp home Bluetooth proxy, I shall have to investigate when I get home as I'm operating remotely right now.
Hm, I'm using ESPHome as bluetooth proxy as well. Also getting somewhere with ble notify and communication stuff:
Essentially got the same byte array as with the native esphome component now.
I have wired some entities to the bluetooth data I get from the device. Mode and the channel numbers (for 4 channels right now) should show up and represent what is set in the fluval led. It's not sending stuff to the LED yet, so no changing lights for now ;)
It this an integration for Fluval lights into HA? This is a neat idea! I have been using your esphome custom component as describe here. I have a separate esp32 device that connects to 2 of my lights, but since I can't really control them as easily on the Bluetooth app, I mainly just use it to auto-sync the time or manual changes whenever I need it. But this would be a great integration to view the status of the light spectrum throughout the day. I use a similar integration for AqauIllumination lights while still being able to set the schedule on the app, and read the light status in HA. I just like to collect Data, but when the lights are in Pro mode, the esp component cannot read the light spectrum status, but would this be able to do that? Currently I added this repo to HACS, but it cannot install just yet to try it out. Here's my Repo of my Fluval Device.
Here's my AI light graph and control:
And the Fluval LED:
And the current HACS error. It may be b/c HACS was updated to 2.0:
EDIT: One limitation I could see if the proximity of the HA instance in relation to the lights themselves. I don't know how it would work (I am just an amateur 'coder') but a cool way to do this would be using an ESP32 device to connect to the devices, then use a HA integration to control them as if the HA was just like the Fluval app. I would like to help out, but my skills are VERY limited. What would have done so far is very useful and I appreciate your work into this, nonetheless!
EDIT: Got this installed manually! But I think the HA instance is just a little too far from the lights, no entities are populating. Also, is it possible to read the light state in Pro mode or does it have to be in Manual? I prefer a HA agnostic control, via the app, while HA can also read the states of the LED spectrums, while also able to manually control at times. I like the setup process on the app, as it is easier, plus you get the gradual ramp up/down as expected, while still being independent of HA. Basically a clone of the FluvalSmart app into HA would be a major leap forward, if possible.
That all being said, I am experimenting this this Integration, Lightener that allows you to control multiple lights with just one global control. I set each spectrum as a light, and set the levels based on the brightness of the blue spectrum (ie if blue was at 100%, red will max out at 25%, and if blue was at 50%, red would be off). Then use this Integration, Scheduler to set the Global light brightness based on time of day. The only thing you loose is the gradual ramp up/down (which you can mitigate with finer tuning of time triggers, but that's a lot of work) and it depends on HA. So if HA goes down, or if the ESP32 device loses connection, it will miss a light state change. Not quite ideal but closer to integrating into HA.
Hi @TheRealFalseReality
Sorry for taking so long to answer - yes, this is at some point going to be fluval integration for HA which will be independant of EPS32 for bluetooth communication, but will use the HA integrated bluetooth stuff. This might be an esp32 as bluetooth proxy, a bluetooth adapter on the HA host or something else. As long as it is reachable by bluetooth from HA, it should work.
I think the esp32 bluetooth proxy would be what your first edit describes: Place an esp32 near your tank and use it as bluetooth proxy. It would connect to the lights with bluetooth and "translates" it to wifi, where it would show up as "native" bluetooth device in HA.
But I am currently very limited on time so development stopped for the moment. Unfortunately at a point where this integration here is in a sorry state and not of much use yet. I left it that way for now, since I rather have something useless than something broken and possibly dangerous to either HA or your fish. But it will resume at some point. I need to improve on Python and the general HA ecosystem before - and this takes some time as well. Usually I have most free time around the end of the year, which is approaching kind of fast (at least for me...)
Unfortunately, at the current point I have no idea on how to request light levels from the fluval lights, if they run in auto/pro mode. The lights are just "running their schedule" which has been set by the app - but not sending out any information about the color channels at all. I will take a closer look and try to reverse engineer the protocol some more to see, if there is a "request light status" command when the integration is finished, but I fear there won't be any. This is a device limitation of fluval, who never thought much about 3rd party integration at all ;)
Best regards mrzottel
Thanks @mrzottel for the response! And good work so far regardless.
It's nice to be able to resync the time on power loss (I live in FL. and Hurricanes and Tornadoes always mess with the power) and control it manually rather quickly without having to reconnect to each light manually through the phone!
I'll have to take a look at the Bluetooth proxy, I've never really messed with Bluetooth on the esp32 until now that I am using this repo, it takes so much memory... And HA is on an RP5, so I'll check that out, thanks!
And yes I was thinking it may not be broadcasting the light state like in manual as you said. Almost had it all! But a way I am testing is having an automation set to Pro for Dawn/Dust ramp up/downs, as well as night/moon settings, and setting to Manual for the simple, daylight setting, just to get that data into a pretty graph. I'd prefer HA to not directly control the schedule, as it is just an extra point of failure, but for that 8 hour day setting, it should be ok.
I am also limited in programming, and I have only made simple scripts, in python, so I would be of no use. I have been leveraging ESPHome to build firmware for a device for simple sensors and some control called AquaPi, and sending that data in HA. From this projects, I have plenty of extra esp32 boards to play with.
Could the very basic skeleton code be uploaded and a number of issues created for things that need done to create an MVP of this? :) That way if you have little time folk could create forks and PRs or bits and pieces that even if you don't use, you'd have some idea code to get the ball rolling :)