Fluval Aquasky BLE RGB-Light

Thank you for this, not really after help but sharing my experience for if of use to anyone.

Ive just flashed an ESP32-WROOM-32 with this. I have two Aquasky Fluval LED’s working well. It had me worried for a bit not connecting and then just clicked into working. I’m having some reliability issues with one of the lights but I think this is down to location of the ESP and BLE through water, I’m experimenting with where to site it as ideally is under the tank but it doesn’t seem to work, as soon as I move it to the side it clicks into life.

esphome:
  name: "fishtankcontroller"

esp32:
  board: esp32dev
  framework:
    type: esp-idf
    version: recommended

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
   key: "XXXXXXXXXXXXXXXXXXXXX"


wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

external_components:
  - source: github://mrzottel/esphome@fluval_ble_led
    components: [ fluval_ble_led ]

time:
  - platform: homeassistant
    id: ha_time

esp32_ble_tracker:

ble_client:
   - mac_address: 44:A6:XX:XX:XX:XX
     id: BLETankFrontClient
   - mac_address: 44:A6:XX:XX:XX:XX
     id: BLETankBackClient

fluval_ble_led:
   - ble_client_id: BLETankFrontClient
     time_id: ha_time
     number_of_channels: 4
     id: BLETankFront
   - ble_client_id: BLETankBackClient
     time_id: ha_time
     number_of_channels: 4
     id: BLETankBack

sensor:    
  - platform: fluval_ble_led
    fluval_ble_led_id: BLETankFront
    channel: 1      
    zero_if_off: true
    name: "Front Channel Red"

  - platform: fluval_ble_led
    fluval_ble_led_id: BLETankFront
    channel: 2      
    zero_if_off: true
    name: "Front Channel Green"  

  - platform: fluval_ble_led
    fluval_ble_led_id: BLETankFront
    channel: 3      
    zero_if_off: true
    name: "Front Channel Blue"  

  - platform: fluval_ble_led
    fluval_ble_led_id: BLETankFront
    channel: 4      
    zero_if_off: true
    name: "Front Channel White" 

  - platform: fluval_ble_led
    fluval_ble_led_id: BLETankBack
    channel: 1      
    zero_if_off: true
    name: "Back Channel Red"

  - platform: fluval_ble_led
    fluval_ble_led_id: BLETankBack
    channel: 2      
    zero_if_off: true
    name: "Back Channel Green"  

  - platform: fluval_ble_led
    fluval_ble_led_id: BLETankBack
    channel: 3      
    zero_if_off: true
    name: "Back Channel Blue"  

  - platform: fluval_ble_led
    fluval_ble_led_id: BLETankBack
    channel: 4      
    zero_if_off: true
    name: "Back Channel White" 

text_sensor:
  - platform: fluval_ble_led
    fluval_ble_led_id: BLETankFront
    name: "Front Mode"
  - platform: fluval_ble_led
    fluval_ble_led_id: BLETankBack
    name: "Back Mode"

button:  
  - platform: fluval_ble_led
    fluval_ble_led_id: BLETankFront
    mode: "MANUAL"
    name: "Front Switch to manual"

  - platform: fluval_ble_led
    fluval_ble_led_id: BLETankFront
    mode: "AUTO"
    name: "Front Switch to auto"

  - platform: fluval_ble_led
    fluval_ble_led_id: BLETankFront
    mode: "PRO"
    name: "Front Switch to pro"

  - platform: fluval_ble_led
    fluval_ble_led_id: BLETankBack
    mode: "MANUAL"
    name: "Back Switch to manual"

  - platform: fluval_ble_led
    fluval_ble_led_id: BLETankBack
    mode: "AUTO"
    name: "Back Switch to auto"

  - platform: fluval_ble_led
    fluval_ble_led_id: BLETankBack
    mode: "PRO"
    name: "Back Switch to pro"

number:
  - platform: fluval_ble_led
    fluval_ble_led_id: BLETankFront
    name: "Front Channel Red"
    channel: 1
    zero_if_off: true

  - platform: fluval_ble_led
    fluval_ble_led_id: BLETankFront
    name: "Front Channel Green"
    channel: 2
    zero_if_off: true

  - platform: fluval_ble_led
    fluval_ble_led_id: BLETankFront
    name: "Front Channel Blue"
    channel: 3
    zero_if_off: true

  - platform: fluval_ble_led
    fluval_ble_led_id: BLETankFront
    name: "Front Channel White"
    channel: 4
    max_value: 1000
    step: 10
    zero_if_off: true

  - platform: fluval_ble_led
    fluval_ble_led_id: BLETankBack
    name: "Back Channel Red"
    channel: 1
    zero_if_off: true

  - platform: fluval_ble_led
    fluval_ble_led_id: BLETankBack
    name: "Back Channel Green"
    channel: 2
    zero_if_off: true

  - platform: fluval_ble_led
    fluval_ble_led_id: BLETankBack
    name: "Back Channel Blue"
    channel: 3
    zero_if_off: true

  - platform: fluval_ble_led
    fluval_ble_led_id: BLETankBack
    name: "Back Channel White"
    channel: 4
    max_value: 1000
    step: 10
    zero_if_off: true

switch:
- platform: fluval_ble_led
  fluval_ble_led_id: BLETankFront
  name: "Front LED Switch"
- platform: fluval_ble_led
  fluval_ble_led_id: BLETankBack
  name: "Back LED Switch"
    

Good evening,

I’ve been running this for a couple of weeks now and really pleased with it, particularly that it turns the lights on and off at sensible times rather than the Fluval app driven automation that seemed to drift and be on and off at odd times.

However I’ve got it being driven by an automation and some scenes at varying times of the day and when they trigger it doesn’t always implement in both of my two lights, it seems to be random which misses and its not all the time. I’ve been thinking that I probably need some sort of watchdog to see if it has implemented the scene when triggered.

Would you suggest this is best implemented in the automation or is it best in the ESP itself?

Thank you for your work on this!

I have 2 AquaSky 2.0s and neither works – I have two ESP32s, each trying to connect to one, with virtually identical configs:

 substitutions:
    devicename: fluval-proxy-breeder
    devicemac: 44:A6:E5:redacted
    address: 192.168.2.27
    ble_client_id: breeder_client
    fluval_ble_led_id: breeder
    
esphome:
  name: $devicename
  project:
    name: aquariums.$devicename
    version: "1.0"
    
esp32:
  #  board: esp32doit-devkit-v1
  #framework:
  #  type: arduino
  board: esp32dev
  framework:
    type: esp-idf
    version: recommended
    
# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: redacted

ota:
  password: "redacted" 
    
wifi:
  ssid: "redacted"
  password: "redacted"
  use_address: $address
  fast_connect: true

esp32_ble_tracker:

ble_client:
  - mac_address: $devicemac
    id: $ble_client_id

time:
  - platform: homeassistant
    id: ha_time


external_components:
  - source: github://mrzottel/esphome@fluval_ble_led
    components: [ fluval_ble_led ]


fluval_ble_led:
  - ble_client_id: $ble_client_id
    time_id: ha_time
    number_of_channels: 4
    id: $fluval_ble_led_id

button:
  - platform: fluval_ble_led
    fluval_ble_led_id: $fluval_ble_led_id
    mode: "MANUAL"
    name: "Switch to manual"

  - platform: fluval_ble_led
    fluval_ble_led_id: $fluval_ble_led_id
    mode: "AUTO"
    name: "Switch to auto"

  - platform: fluval_ble_led
    fluval_ble_led_id: $fluval_ble_led_id
    mode: "PRO"
    name: "Switch to pro"

sswitch:
  - platform: fluval_ble_led
    fluval_ble_led_id: $fluval_ble_led_id
    name: "light"

text_sensor:
  - platform: fluval_ble_led
    fluval_ble_led_id: $fluval_ble_led_id
    name: "mode"

sensor:
  - platform: fluval_ble_led
    fluval_ble_led_id: $fluval_ble_led_id
    channel: 1
    zero_if_off: true
    name: "Green"

  - platform: fluval_ble_led
    fluval_ble_led_id: $fluval_ble_led_id
    channel: 2
    zero_if_off: true
    name: "Cold white"

  - platform: fluval_ble_led
    fluval_ble_led_id: $fluval_ble_led_id
    channel: 3
    zero_if_off: true
    name: "Blue"

  - platform: fluval_ble_led
    fluval_ble_led_id: $fluval_ble_led_id
    channel: 4
    zero_if_off: true
    name: "Rose"

number:
- platform: fluval_ble_led
  fluval_ble_led_id: $fluval_ble_led_id
  name: "Green"
  channel: 1
  zero_if_off: true

- platform: fluval_ble_led
  fluval_ble_led_id: $fluval_ble_led_id
  name: "Cold White"
  channel: 2
  zero_if_off: true

- platform: fluval_ble_led
  fluval_ble_led_id: $fluval_ble_led_id
  name: "Blue"
  channel: 3
  zero_if_off: true

- platform: fluval_ble_led
  fluval_ble_led_id: $fluval_ble_led_id
  name: "Rose"
  channel: 4
  zero_if_off: true

MOST of the time, they both refuse to connect with the following error:

[08:52:12][D][esp32_ble_tracker:266]: Starting scan...
[08:52:15][D][esp32_ble_client:110]: [0] [44:A6:E5:70:00:34] Found device
[08:52:15][D][esp32_ble_tracker:661]: Found device 44:A6:E5:70:00:34 RSSI=-81
[08:52:15][D][esp32_ble_tracker:682]:   Address Type: PUBLIC
[08:52:15][D][esp32_ble_tracker:684]:   Name: '40B'
[08:52:15][D][esp32_ble_tracker:687]:   TX Power: 2
[08:52:15][D][esp32_ble_tracker:215]: Pausing scan to make connection...
[08:52:15][I][esp32_ble_client:067]: [0] [44:A6:E5:70:00:34] 0x00 Attempting BLE connection
[08:52:16][D][esp-idf:000]: W (21614232) BT_HCI: hcif disc complete: hdl 0x0, rsn 0x3e

[08:52:16][D][esp-idf:000]: W (21614336) BT_HCI: hcif disc complete: hdl 0x0, rsn 0x3e

[08:52:16][D][esp-idf:000]: W (21614441) BT_HCI: hcif disc complete: hdl 0x0, rsn 0x3e

[08:52:17][D][esp-idf:000]: W (21615490) BT_APPL: gattc_conn_cb: if=3 st=0 id=3 rsn=0x3e

[08:52:17][D][esp-idf:000]: W (21615498) BT_HCI: hcif disc complete: hdl 0x0, rsn 0x3e

[08:52:17][D][esp32_ble_client:172]: [0] [44:A6:E5:70:00:34] ESP_GATTC_DISCONNECT_EVT, reason 62
[08:52:17][W][fluval_ble_led:229]: Disconnected from Fluval LED. Resetting handshake.
[08:52:17][D][esp32_ble_client:110]: [0] [44:A6:E5:70:00:34] ESP_GATTC_OPEN_EVT
[08:52:17][W][esp32_ble_client:143]: [0] [44:A6:E5:70:00:34] Connection failed, status=133
[08:52:17][D][esp32_ble_tracker:266]: Starting scan...

Weirdly, occasionally they will connect. It appears that they ONLY connect after a reboot – and sometimes after a reboot, they will not connect to wireless, so I suspect there is something going on with the BLE/WiFi interaction.

These are on ESP-wroom-32s.

Any advice would be appreciated.

Are you still using the same board you mentioned way back when? I ordered a couple of different boards to see if perhaps that’s the issue.

Hi @ashmandias,

yeah, I’m still using the same board and still without issues. Do you have by chance the fluval app open and connecting to the lights first? Unfortunately, the lights can only handle a single connection - so it’s either app or esp.

For me I solved this issue with disabling the esp if I need to connect with the app (for example to change the “pro” lighting profiles) - then I stop/disconnect the app and enable the esp again.

This would also fit why it would connect after reboot sometimes - depending on wether the app or esp connects faster. :wink:

PS: The board I am using is the “az-delivery-devkit-v4”. It’s still available here in Germany, but other people managed to connect with other boards, which might be better available in your location.

Best regards
mrzottel

@mrzottel I think I resolved this – while I can connect to either light from anywhere in the house with my phone, the transmitter on the esp BT must be far, far weaker than my phones – I get 90% failures to connect when I am 6 foot away (horizontally) from the lights, and 100% if the esp is underneath the tank, even though my phone connects just fine from both places.

If I move the esp to ~12 inches from the lights themselves (or less), it looks like it connects 100% of the time. No idea why the range is so crazy short, though. It is interesting to note that I got bit by generic error messages – other users in this thread had similar errors, with different resolutions.

I’m new to the ESP world, and I am looking into the esp32-wroom-32U – they have a port for an external antenna and I am trying to figure out if that would help with the BT connections, perhaps allowing me to use one ESP for both my current tanks.

thanks!

I’m still new to ESPHome – but what would it take to get fluval_ble_led to function as a light_component? It seems like if we can make that jump, we can take advantage of a lot of additional built in options.

thanks!

Great that you resolved it. The board I am using has the ESP soldered on in a way that the built in antenna is not blocked by the board below (like a big ground plane or something, which tends to do that - but still the range is limited to a few meters… At least it works for me with the ESP directly below the fish tank in the cabinet. :wink:

Unfortunately, I have no clue how to make a light component out of this as well - I am quite new to the whole stuff myself :wink: But I think the biggest limiting factor is, that the fluval led does not “behave” much like a regular light in that it needs regular time updates, has 4 or 5 channels which do not really map to RGB that well (like the Fluval Plant with pink, blue, cold white, pure white and warm white) - and also switching modes between manual, automatic and professional is something most lights don’t do. (with the later two modes disabling direct channel control completely)

What additional options are you missing though?

Best regards
mrzottel

If I understand things correctly, if it’s a ‘light component’ you can use the fancy light button on dashboards that allow you to select the color directly, as well as use “light effects” and set up transitions when the you change settings.

I am currently trying to wrap my head around things, and figure out how to get my Fluval Aquasky 2.0 to smoothly transition from one set of RGB values to another, over the course of an hour or so – that’s a big feature that the stock app can’t do that seems possible with this set up.

Transition effects and response to colour wheel, RGB settings etc are device dependent. I have what is essentially an RBGWW smart bulb (RGB with cool and warm white) from a cheap Chinese brand. Transition effects are not supported with this bulb and as soon as I try to use home assistant to manually add just a little white using an automation it totally overrides any RGB-I was hoping to use it to mimic sunrise and sunset for a pet. I can do what I want with a philips hue bulb though

Well, my alternative plan is to try and write some code to mimic this. Since the Fluvals all accept values to set the lights to, it should not be terribly difficult to write something that accepts RGB values, and a length of time. Then you just pull the current values and transition from the current settings to the new settings over that length of time. It’s not pretty, and I will have to learn how to do it in Home Assistant, but it will achieve the same goal.

Hey there is there a simple tutorial i could folow not worked with esp32 and homeassistant

I’ve just ventured onto this and I think its brilliant all the work you have done. I also think that parts of this element could be altered to import the Hass Light component and behave like a RGBW light. It wouldn’t stop you from exposing other buttons/sensors etc. I did wonder if its better to create a custom component for Home assistant, I haven’t had a lot of experience with python, or Home Assistant development work but I’m willing to give it a try. My thoughts would be that it would allow you to move away from having this on dedicated BLE Clients and utilise BLE Proxy. The hard work of decoding all the values has been done, might be a case of looking at HACS frameworks, you can then import the integrations direct from Github.

I’m just having a read through this: Custom Repositories | HACS

Edit: Just spotted in the thread you are looking at HACs and a native intergration. Im a willing volunteer for testing and day time work for a software house let me know if i can assist. Fluval aquasky 750 at disposal.

The issue I can foresee is “colour space conversion”. These aren’t RGB so I don’t know how someone could map the colours in the fluval lights to the controls that HA uses for controlling coloured lights, whether that is RGB or RGBW. I don’t want to stop people trying I am just aware this is way more complicated than people may think

1 Like

Just got an Aquasky 2 and had it up and running in all of 5 minutes with this. Superb work!

Has anyone done any work towards getting a sunrise/sunset/night sequence programmed?

wow, I can’t believe this works! I was looking into the AquaIllumination WiFi lights, got that into HA and I thought, what about my Fluvals? I thought well no, they are Bluetooth. But I searched and saw this! I have so many esp32 devices around the house…
I will try this out tonight, I created something that uses ESP32 devices to monitor fish tanks, this would be a great optional addition!

I made something called the AquaPi, modular & customizable device:

Dude thank you for your hard work on this. I was about to do all this work manually and then I was like man I should look and see if anyones done this. Installed it on my esp and used someone elses example. Wasnt working perfectly then I realized that my light has different colors and channels than the person I copied. Swapped them out and bam its perfect. Thanks so much.

Its basically as follows:

setup esp-home (using esp home addon for HA), i suggest doing it on mac or windows. (install gitforwindows as well). then start it from within the github cmd.

next is to install the matching drivers for your esp32 board’s chip. (ESPhome leads you)

now lets have some fun and create a yaml file like mine: (based on publications released here, credit to those having created it :slight_smile: )

esphome:
  name: "fishtankcontroller"

esp32:
  board: esp32dev
  framework:
    type: esp-idf
    version: recommended

# Enable logging
logger:
  level: DEBUG
# Enable Home Assistant API
api:
  encryption:
   key: "S/lJYWLR+FYCBHhX1sjmyAU5IE/YoO3FKBlrAdeJapo="


wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

external_components:
  - source: github://mrzottel/esphome@fluval_ble_led
    components: [ fluval_ble_led ]

time:
  - platform: homeassistant
    id: ha_time

esp32_ble_tracker:

ble_client:
   - mac_address: 44:A6:E5:6E:0E:D1
     id: BLETankFrontClient

fluval_ble_led:
   - ble_client_id: BLETankFrontClient
     time_id: ha_time
     number_of_channels: 4
     id: BLETankFront


sensor:    
  - platform: fluval_ble_led
    fluval_ble_led_id: BLETankFront
    channel: 1      
    zero_if_off: true
    name: "Front Channel Red"

  - platform: fluval_ble_led
    fluval_ble_led_id: BLETankFront
    channel: 2      
    zero_if_off: true
    name: "Front Channel Green"  

  - platform: fluval_ble_led
    fluval_ble_led_id: BLETankFront
    channel: 3      
    zero_if_off: true
    name: "Front Channel Blue"  

  - platform: fluval_ble_led
    fluval_ble_led_id: BLETankFront
    channel: 4      
    zero_if_off: true
    name: "Front Channel White" 

text_sensor:
  - platform: fluval_ble_led
    fluval_ble_led_id: BLETankFront
    name: "Front Mode"

button:  
  - platform: fluval_ble_led
    fluval_ble_led_id: BLETankFront
    mode: "MANUAL"
    name: "Front Switch to manual"

  - platform: fluval_ble_led
    fluval_ble_led_id: BLETankFront
    mode: "AUTO"
    name: "Front Switch to auto"

  - platform: fluval_ble_led
    fluval_ble_led_id: BLETankFront
    mode: "PRO"
    name: "Front Switch to pro"

number:
  - platform: fluval_ble_led
    fluval_ble_led_id: BLETankFront
    name: "Front Channel Red"
    channel: 1
    zero_if_off: true

  - platform: fluval_ble_led
    fluval_ble_led_id: BLETankFront
    name: "Front Channel Green"
    channel: 2
    zero_if_off: true

  - platform: fluval_ble_led
    fluval_ble_led_id: BLETankFront
    name: "Front Channel Blue"
    channel: 3
    zero_if_off: true

  - platform: fluval_ble_led
    fluval_ble_led_id: BLETankFront
    name: "Front Channel White"
    channel: 4
    max_value: 1000
    step: 10
    zero_if_off: true


switch:
- platform: fluval_ble_led
  fluval_ble_led_id: BLETankFront
  name: "Front LED Switch"

the mac-adress can be found inside the fluval app, when swiping the light to the left and selecting “upgrade”. the secret is used for pairing iwth your HA instance when adding the final device there.

now lets verify and install the code to the board.

next is wait a little, remove power and place it near the fluval light permanently.

up next is debugging.
inside the dashboard (can be started using “esphome dashboard .” from within github cmd) you can also find the log button for your new device and check for issues.

thats with my aquasky 2.0 // 16w.
values are published as “number.name” to HA.

—> if getting reception / connection issues, like mentionen before in this treath,
try moving the board to a place that is on the same hight as the fluval light.

i did get some cheap esp32dev boards, from within germany (8€/each) on ebay.
Have to basically place it right nex tto the light, since fluvals integrated BT-Chip seems to be very week as well as my board’s.

i hope the az-delivery boards are better in this term, but for now using panzertape it works just fine :smiley:

Next step:
generating a virtual light with wrgb mode support:

this is my configuration.yaml:

light:
  - platform: template
    lights:
      fluval_wrgb:
        unique_id: 28208f257b54c44e50deb2d618d44710
        friendly_name: "wrgb fluval"
        value_template: >-
          {% if is_state('light.aquarium_60l', 'on') %}
            on
          {% else %}
            off
          {% endif %}
        rgbw_template: >
          [
            {{ (state_attr('input_number.lichtstaerke_rot_aq60_hauptlicht', 'value') * 2.55) | int }},
            {{ (state_attr('input_number.lichtstaerke_gruen_aq60_hauptlicht', 'value') * 2.55) | int }},
            {{ (state_attr('input_number.lichtstaerke_blau_aq60_hauptlicht', 'value') * 2.55) | int }},
            {{ (state_attr('input_number.lichtstaerke_weiss_aq60_hauptlicht', 'value') * 2.55) | int }}
          ]
        availability_template: "{{ not is_state('light.fluval_wrgb', 'unknown') }}"
        turn_on:
          service: light.turn_on
          entity_id: light.aquarium_70l
        turn_off:
          service: light.turn_off
          entity_id: light.aquarium_70l
        set_rgbw:
          service: input_number.set_value
          entity_id: light.fluval_wrgb
          data:
            rgbw_color:
              - "{{ (r / 2.55) | int }}"
              - "{{ (g / 2.55) | int }}"
              - "{{ (b / 2.55) | int }}"
              - "{{ (w / 2.55) | int }}"

as of now it is showing up correctly:



also linking to the state of my fluval light’s status (on/off) entity works correct.


What else did i do?
Made entites to work with 0-100 in steps of 1, that scale to 0-1000 in steps of 100.
Link these together for smoother look in dashboard (and unified handling oc).
Create virtual color preset buttons that work across my chihiros and fluval lights.
(thats what i need to unfied handling for)

→ created 4 input_number entites as helpers and set them “0-100,steps of 10”
→ made a function node in nodeRed, that scales 0-1000 by 10 to 0-100 by 1. It also checks for “msg.entity” to detect where to send the new value to. So i can have 1 node for chanigng all 4 values + 1 node to publish the new ones:


// Extract entity_id and state from msg
let entityId = msg.data.entity_id; // Get the entity_id from msg.data
let stateValue = parseFloat(msg.payload); // Convert msg.payload to a float

// Ensure stateValue is within the expected range
if (isNaN(stateValue) || stateValue < 0 || stateValue > 100) {
    node.error("State value must be a number between 0 and 100.", msg);
    return null;
}

// Scale the state value from 0-100 to 0-1000
let scaledValue = stateValue * 10;

// Map the input_number entity to the corresponding light number entity
let mappedEntityId;

switch (entityId) {
    case "input_number.lichtstaerke_rot_aq60_hauptlicht":
        mappedEntityId = "number.light_aquarium_60l_red";
        break;
    case "input_number.lichtstaerke_blau_aq60_hauptlicht":
        mappedEntityId = "number.light_aquarium_60l_blue";
        break;
    case "input_number.lichtstaerke_gruen_aq60_hauptlicht":
        mappedEntityId = "number.light_aquarium_60l_green";
        break;
    case "input_number.lichtstaerke_weiss_aq60_hauptlicht":
        mappedEntityId = "number.light_aquarium_60l_white";
        break;
    default:
        node.error("Unrecognized entity_id: " + entityId, msg);
        return null;
}

// Prepare the message for the call service node
msg.payload = {
    domain: "number",
    service: "set_value",
    data: {
        entity_id: mappedEntityId,
        value: scaledValue
    }
};

// Optionally clean up the msg object to include only payload
delete msg.data;
delete msg.entity;

return msg;

This provides me with 4 entities that range from 0-100 and therefore fit much better with percentage readings / displaying.

→ next have a reverse node to update the scaled values when changing directly on the lights entities:

// Access the Home Assistant state from the global context
let lightState = global.get('homeassistant.homeAssistant.states');

// Get the state of the specific entity (e.g., light.aquarium_60l)
let entityState = lightState["light.aquarium_60l"].state;

// Check if the entity's state is "on"
if (entityState === "on") {

// Extract entity and value from msg
let entityId = msg.data.entity_id; // Get the entity_id from msg.data
let value = parseFloat(msg.payload); // Convert msg.payload to a float

// Ensure value is within the expected range
if (isNaN(value) || value < 0 || value > 1000) {
    node.error("Value must be a number between 0 and 1000.", msg);
    return null;
}

// Scale the value from 0-1000 to 0-100
let scaledValue = value / 10;

// Map the number entity to the corresponding input_number entity
let mappedEntityId;

switch (entityId) {
    case "number.light_aquarium_60l_red":
        mappedEntityId = "input_number.lichtstaerke_rot_aq60_hauptlicht";
        break;
    case "number.light_aquarium_60l_blue":
        mappedEntityId = "input_number.lichtstaerke_blau_aq60_hauptlicht";
        break;
    case "number.light_aquarium_60l_green":
        mappedEntityId = "input_number.lichtstaerke_gruen_aq60_hauptlicht";
        break;
    case "number.light_aquarium_60l_white":
        mappedEntityId = "input_number.lichtstaerke_weiss_aq60_hauptlicht";
        break;
    default:
        node.error("Unrecognized entity_id: " + entityId, msg);
        return null;
}

// Prepare the message for the call service node
msg.payload = {
    domain: "input_number",
    service: "set_value",
    data: {
        entity_id: mappedEntityId,
        value: scaledValue
    }
};

// Optionally clean up the msg object to include only payload
delete msg.data;
delete msg.entity;

return msg;
}
else {}

to this point linkage works perfectly fine, i always see my lights brightness vlaues in range 0-100. ofc i can modify the light from there as well.

2024-08-17 21.35.06 192.168.0.42 fef1963c7ffe

→ whats next?
please someone help me with the wrgb part of the virtual light, since atm i can play around the color wheel but it does not change my input_number.* values - no matter what i change / try. its important to know that the value of the lights must rang 0-255. I guess its much easier to scale them outside of the template light.

in short:
so if someone gets the configuration.yaml code right,
so that it stores and accesses a number.* or input_number.* entity per color + white, we can enjoy having a true light entity to setup our lights.

another solution:
if one color gets 1 entity, it would be more flexible to fine tune your lighting.
this is the case with the chihiros integration, which you can find here:

2024-08-18 08.24.33 192.168.0.42 fe7f64108e05



here is how i handle color presets based on the above:
create some input.boolean helper in HA and link it to another action node.
link the action node to a call service node.

Function:

// Create an array to hold the messages
let msgs = [];

// Red light service call
msgs.push({
    payload: {
        domain: "input_number",
        service: "set_value",
        data: {
            entity_id: "input_number.lichtstaerke_rot_aq60_hauptlicht",
            value: 75
        }
    }
});

// Green light service call
msgs.push({
    payload: {
        domain: "input_number",
        service: "set_value",
        data: {
            entity_id: "input_number.lichtstaerke_gruen_aq60_hauptlicht",
            value: 42
        }
    }
});

// Blue light service call
msgs.push({
    payload: {
        domain: "input_number",
        service: "set_value",
        data: {
            entity_id: "input_number.lichtstaerke_blau_aq60_hauptlicht",
            value: 25
        }
    }
});

// White light service call
msgs.push({
    payload: {
        domain: "input_number",
        service: "set_value",
        data: {
            entity_id: "input_number.lichtstaerke_weiss_aq60_hauptlicht",
            value: 70
        }
    }
});

// Return the array of messages
return [msgs];



1 Like

Hello everyone

I have just got into HA, and was wondering about my two Fluval lights (Plant 3.0 and Aquasky 2). I have stumbled across, and read, this thread and have actually made an account to comment lol.

I have tried to download the file in HACS and am getting an error message.


Fluval Aquarium LED

Commit 19c52b0 will be downloaded

When downloaded, this will be located in '/config/custom_components/fluvalble'

Remember that you need to restart Home Assistant before changes to integrations (custom_components) are applied.

The version 19c52b0 for this integration can not be used with HACS.


I would love to test this with my two tanks. My programming knowledge is practically nil (unless you count when I did Turbo Pascal about 20 years ago). Yet I would love to be able to help if this is still an ongoing project? Im in the UK if that makes any difference.

Thanks all :slight_smile: