So, about testing:
Please, if possible, use a dedicated ESP32 for testing. Things might crash, so be warned
At first, import the fluval_ble_led component with this code:
external_components:
- source: github://mrzottel/esphome@fluval_ble_led
components: [ fluval_ble_led ]
And we also need a time source, as the Fluval LEDs require a set time for their auto/pro stuff to work correctly. I use the easiest option - get time from the HA itself. But others will work too:
time:
- platform: homeassistant
id: ha_time
It is important that this time source has an ID, so we can reference it later.
Next is the esp32_ble_tracker, which allows us to find and treck Bluetooth Low Energy devices:
esp32_ble_tracker:
No special configuration needed here.
Then we need the ble_client to handle the basic connection to the Fluval LED as well as sending and receiving packets:
ble_client:
- mac_address: 44:A6:E5:69:7E:8D
id: my_ble_client
The mac address is the mac of the Fluval LED. To figure this one out I used an app called nRF Connect on my smartphone, which listed all broadcasting BLE devices in the vicinity. My Fluval LEDs showed up with their name, so it was easy to find their mac addresses. They all started with 44:46:E5 in my case. Also please make sure that you are not connected with the Fluval App to the light. It won’t advertise when connected, and you will not be able to find it in nRF Connect!
Once the ble_client is configured, we can start using the fluval_ble_led component like this:
fluval_ble_led:
ble_client_id: my_ble_client
time_id: ha_time
number_of_channels: 4
id: my_fluval_led
The Fluval component needs the ID of the previously created ble client as well as the ID of the time source. Number_of_channels is set to 4 in my case, as I only own a couple of AquaSky 2.0 lights, which are RGBW. The Marine, Plant and some other lights will have 5 channels, so either enter 4 or 5 here, depending on the light you are connecting. If you by chance have a light with less than 4 or more than 5 channels please contact me
Lastly, the fluval_ble_led needs an ID of its own, so we can use it in sensors / buttons / switches.
All the following switches/buttons/sensors only work in manual mode, as “auto” and “pro” modes do not publish any channel information and won’t accept color changes. They are automatic programs after all
There is currently one switch defined for the Fluval component: LED on/off.
switch:
- platform: fluval_ble_led
fluval_ble_led_id: my_fluval_led
name: "LED Switch"
Pretty forward: This lets you switch on/off your LED in manual mode. It also gets feedback from the LED, so it should reflect the current state.
There are 3 buttons to switch between the modes:
button:
- platform: fluval_ble_led
fluval_ble_led_id: my_fluval_led
mode: "MANUAL"
name: "Switch to manual"
- platform: fluval_ble_led
fluval_ble_led_id: my_fluval_led
mode: "AUTO"
name: "Switch to auto"
- platform: fluval_ble_led
fluval_ble_led_id: my_fluval_led
mode: "PRO"
name: "Switch to pro"
These allow you to switch between the 3 modes of the LED - manual, auto, pro. If you have a device which does not support one of the modes, please contact me
To see in which mode the Fluval LED is currently in, there is a text sensor:
text_sensor:
- platform: fluval_ble_led
fluval_ble_led_id: my_fluval_led
mapping_manual: "Manuell"
mapping_auto: "Automatisch"
mapping_pro: "Professionell"
name: "Mode"
As you can see, it supports mapping of the modes to your own language, in this case german. This is optional though (Does not make much sense here, but I used it for demonstration purposes )
Similar to the modes, there are also sensors which can display the channel values for the different channels:
sensor:
- platform: fluval_ble_led
fluval_ble_led_id: my_fluval_led
channel: 1
zero_if_off: true
name: "Channel Red"
- platform: fluval_ble_led
fluval_ble_led_id: my_fluval_led
channel: 2
zero_if_off: true
name: "Channel Green"
- platform: fluval_ble_led
fluval_ble_led_id: my_fluval_led
channel: 3
zero_if_off: true
name: "Channel Blue"
- platform: fluval_ble_led
fluval_ble_led_id: my_fluval_led
channel: 4
zero_if_off: true
name: "Channel White"
In my case, I only have 5 channels, RGB and W, so I use 4 channels here. With other lamps you can use the fifth channel as well. “Zero_if_off” means, that the channel value will display as 0 instead as “unknown” if the Fluval LED is not in manual mode. This is an optional setting.
The channel values will range from 0 to 1000 - this is the way the Fluval LED works, sorry for that. I am pretty sure it does not have 1000 distinct levels per channel anyway
Instead - or in addition to - the read only sensors, we can also use number entities to modify those channels in manual mode:
number:
- platform: fluval_ble_led
fluval_ble_led_id: my_fluval_led
name: "Channel Red"
channel: 1
zero_if_off: true
- platform: fluval_ble_led
fluval_ble_led_id: my_fluval_led
name: "Channel Green"
channel: 2
zero_if_off: true
- platform: fluval_ble_led
fluval_ble_led_id: my_fluval_led
name: "Channel Blue"
channel: 3
zero_if_off: true
- platform: fluval_ble_led
fluval_ble_led_id: my_fluval_led
name: "Channel White"
channel: 4
max_value: 500
min_value: 100
step: 10
zero_if_off: true
They are configured almost identical to sensors, including the zero_if_off optional setting. But they display as nice sliders in HA, which in default settings allow to set the value between 0 and 1000 in 100 steps. For demonstration, I configured the white channel to have a maximum value of 500 and a minimum value of 100, in steps of 10. This is possible to do, let’s see if it has a use case You can not exceed a max of 1000 and a minimum of 0 though.
Well, thats it so far - I learned a lot about Bluetooth LE, C++, Python and Home Assist and it was really awesome to work with that - what a beautiful and elegant system. Of course I will stick around and wait for your test results, fix bugs if they come up, implement ideas - the usual stuff. Next will be a more robust reconnect logic, then linting, so the code passes ESPHome tests and meets their standards and maybe I can get the component accepted into their base
But for now, lets test please
Best regards
mrzottel