LimitlessLED NightMode

Would be great to have this setting included in the LimitlessLED component.

Night Mode is like a really dim (dimmer than the first step) setting for the bulb.
Really handy to use as a night light in my son’s bedroom.

OpenHAB has this setting configured for their miilight (LimitlessLED) binding so hoping Hass can implement it too.

There is documentation on the limitlessLED dev site for the NightMode command.

Java commands for Night Mode:

private void sendNightMode(int bulb, String bridgeId) {
        logger.debug("milight: sendNightMode");
        String messageBytes = null;
        String messageBytes2 = null;
        switch (bulb) {
            case 0:
                // message nightMode all white bulbs
                messageBytes = "B9:00:55";
                break;
            case 1:
                // message nightMode white bulb channel 1
                messageBytes = "BB:00:55";
                break;
            case 2:
                // message nightMode white bulb channel 2
                messageBytes = "B3:00:55";
                break;
            case 3:
                // message nightMode white bulb channel 3
                messageBytes = "BA:00:55";
                break;
            case 4:
                // message nightMode white bulb channel 4
                messageBytes = "B6:00:55";
                break;
            case 6:
                // message nightMode all RGBW bulbs
                messageBytes = "41:00:55";
                messageBytes2 = "C1:00:55";
                break;
            case 7:
                // message nightMode RGBW bulb channel 1
                messageBytes = "46:00:55";
                messageBytes2 = "C6:00:55";
                break;
            case 8:
                // message nightMode RGBW bulb channel 2
                messageBytes = "48:00:55";
                messageBytes2 = "C8:00:55";
                break;
            case 9:
                // message nightMode RGBW bulb channel 3
                messageBytes = "4A:00:55";
                messageBytes2 = "CA:00:55";
                break;
            case 10:
                // message nightMode RGBW bulb channel 4
                messageBytes = "4C:00:55";
                messageBytes2 = "CC:00:55";
                break;
        }
        sendMessage(messageBytes, bridgeId);

        // nightMode for RGBW bulbs requires second message 100ms later.
        if (bulb >= 6 && bulb <= 10) {
            try {
                Thread.sleep(100);
                sendMessage(messageBytes2, bridgeId);
            } catch (InterruptedException e) {
                logger.debug("Sleeping thread has been interrupted.");
            }
        }

    }

Hoping this can be implemented for HASS!

Keen for this, too! A very useful feature we use throughout our home. It is the only feature I have found HA hasn’t provided in my setup.

I notice the feature is in https://github.com/ojarva/python-ledcontroller

Are we somehow able to externally call this?

(sorry, just started using HA 4 days ago)

Good find!
I wonder if this code could be integrated into the existing LimitlessLED module for HA or replace it altogether?

It seems more complete (includes night mode) so would be perfect!

Anyone able to offer any assistance on getting this integrated?

Came here to comment on how much I would love to see full integration of support for limitlessLED.
I’m willing to help contribute to get that python lib above to work with Home Assistant but my time is limited.

I’d prefer someone else step up that is more familiar with Home Assistant as I’d want to integrate this into the light platform properly.

1 Like

Hopefully someone is able to help out with this at some point.

yes, I had hoped with the addition of the v6 hub that the feature would have been added. Seems like such a simple addition.

I have night lights working as command line switches, but its not very elegant or well co-ordinated with the ‘real’ HA lights.

@Jman that’s a good idea actually.
Would you mind sharing your command line switches for night mode?

Here it is.

switch section of config.yaml…

- platform: command_line
  switches:
    night_light1:
      friendly_name: 'Desk Light Night Mode'
      command_off: "/bin/bash /home/homeassistant/.homeassistant/nightlight.sh light.desk_light 1 off"
      command_on: "/bin/bash /home/homeassistant/.homeassistant/nightlight.sh light.desk_light 1 night"
      value_template: '{{ return_value == "1" }}'

The following script is based on https://github.com/mrwhale/limitlessled-bash/blob/master/led.sh
my limitless hub hostname is wifilights

/local/nightlight.sh

#!/bin/bash

entity="$1"
zone="$2"
switch="$3"
offarray=("\x39\00" "\x3B\00" "\x33\00" "\x3A\00" "\x36\00")
nightarray=("\xB9\00" "\xBB\00" "\xB3\00" "\xBA\00" "\xB6\00")

# Try sending to /dev/udp. If that fails use netcat
echo -n -e "${offarray[$zone]}" >/dev/udp/wifilights/8899 || echo -n -e "${offarray[$zone]}" | nc -w 1 -u wifilights 8899
sleep 0

if [ $switch = "night" ]
then
    echo -n -e "${nightarray[$zone]}" >/dev/udp/wifilights/8899 >/dev/udp/wifilights/8899 || echo -n -e "${nightarray[$zone]}" | nc -w 1 -u wifilights 8899
    curl -k -X POST -H "x-ha-access: myHaApassword" -H "Content-Type: application/json" -d '{"state": "off"}' http://localhost:8123/api/states/$entity
fi
1 Like

Thanks for that @Jman.
I can’t get it working but obviously something I’m doing wrong. I’ll keep having a play.

Thanks again.

i can help.
One issue you might get caught with is the code needs to match your limitless light.
In my case, my light entity in HA is light.desk_light.

there are 3 parameters passed to the bash script; the light entity, the zone number and the mode to set the light to: either ‘off’ or ‘night’

@Jman yeah I made sure I updated all parameters and set the Hass web password in the X-Post line too.

If i manually run the script with the parameters it updates the Hass UI but doesn’t actually do anything to the lights.

What version is your bridge? Mine is v5.

So, to test the basic function, replacing all the variables with values, and putting the bridge’s ip address in (10.1.1.50 for example), script could look like this…

#!/bin/bash

entity="light.desk_light"
zone="2"
switch="night"
offarray=("\x39\00" "\x3B\00" "\x33\00" "\x3A\00" "\x36\00")
nightarray=("\xB9\00" "\xBB\00" "\xB3\00" "\xBA\00" "\xB6\00")

echo -n -e "${offarray[$zone]}" >/dev/udp/10.1.1.50/8899 || echo -n -e "${offarray[$zone]}" | nc -w 1 -u 10.1.1.50 8899
sleep 0

if [ $switch = "night" ]
then
    echo -n -e "${nightarray[$zone]}" >/dev/udp/10.1.1.50/8899 >/dev/udp/10.1.1.50/8899 || echo -n -e "${nightarray[$zone]}" | nc -w 1 -u 10.1.1.50 8899
    curl -k -X POST -H "x-ha-access: myHaApassword" -H "Content-Type: application/json" -d '{"state": "off"}' http://localhost:8123/api/states/$entity
fi

@Jman ummm must be an issue with my bridge/setup.
I still can’t get it to run.

The entity gets updated in HASS but the action doesn’t execute on the light itself.

I have a v5 bridge too.

does theLimitlessled admin utility work for you?

http://www.limitlessled.com/download/LimitlessLEDv6.zip

When you run it, if it discovers your bridge, does the “Get Protocol” button return protocol as UDP and Port as 8899?

@Jman sorry for the delayed response.
The admin tool used to work for me - It’s not discovering my bridge anymore. Might need to do a bit of troubleshooting to get that side of it working again.

A night mode effect for LimitlessLED was included in Home Assistant 0.64.

Would it be possible to set the colour of the icon darker, or some other effect to indicate the lights are n night mode? They appear as though they’re fully on when viewing hass.

Yes, I will add that.

I’m sorry if this was covered earlier in the post. I didn’t read all of it, but if there is a night mode for LimitlessLED lights how do you access that feature from HA? I didn’t see anything mentioned about night mode in the Limitless LED documentation.

It’s a light effect. If you press the light name in the UI you should be able to select it in the dialog that appears (when the light is on).