Esp8266_milight_hub - activate nightmode from bulb off state

Hi all

I have a number of miligjht / limitless RGBWW bulbs setup using the excellent hub created by sidoh:

It’s connected to my HA using the MQTT broker supervisor addon. MQTT is set to autodiscover them, and they appear as RGB bulbs correctly in HA.

Previously, using the original milight hub and the limitless integration, I was able to have the bulbs off, and turn them on directly into night mode.

However, using HA I can’t work out a way to put them directly into night_mode. I can of course turn them on then select night_mode, but if I’m doing this via an automation with the light.turn_on service with the effectmode flag, they flicker into full power mode before going into nightmode, which is jarring to say the least.

There’s probably a straightforward way to resolve this, but I am new to MQTT and not sure if that’s even the right place to be looking?

Can anyone help with how to get them to turn on directly to night_mode effect?

Much appreciated

Details are sparse :wink:

You mean you cannot call the service light.turn_on while sending, e.g., brightness and/or color at the same time?

Light - Home Assistant (home-assistant.io)

From the project page, it seems possible with the proper payload

client.publish('milight/0x118D/rgb_cct/1', '{"status":"ON","color":{"r":255,"g":200,"b":255},"brightness":100}')

Hi Chris

thanks for the response. I specifically want to call light.turn_on with the “effect” function. Which is possible and works. Sort of.

When I do the following (assuming the light is currently off) it flickers to a full “on” state before engaging the mode. It does this for all modes, not just night_mode.

I wish to avoid this flicker

service: light.turn_on
data:
  effect: 'night_mode'
target:
  entity_id: light.hall

This is a new issue since changing to the mqtt setup / esp controller. Previously with the limitlessled integration and a genuine milight hub, the light would go straight into the effect mode. Unfortunately my genuine hubs died and they’re not replaceable so had to change to the custom esp one.

1 Like

Did you ask this also ad sidoh on GitHub if this is even possible with this build?

Could you please show the mqtt configuration you use?

This is my MQTT config in HA (using the supervisor addon)

logins: []
customize:
  active: false
  folder: mosquitto
certfile: fullchain.pem
keyfile: privkey.pem
require_certificate: false

All ports are defaults.

In configuration.yaml:

mqtt:
  broker: 192.168.60.2
  discovery: true
  discovery_prefix: homeassistant
  username: !secret milight_mqtt_username
  password: !secret milight_mqtt_password

This is the MQTT config in the milight hub:


Not yet. I assume it should be possible as from the controller itself you can select the mode and it comes on correctly without flashing the bulb. That’s why I thought it might be an MQTT setup thing. I am guessing if I manually configure the bulbs rather than using autodiscover I might be able to get it working?

Thanks, but where is the code that pushes on the milight topic?

It’s not explicitly / manually entered as mqtt is set to “discovery: true”.

My understanding is that it can query (discover) the device (milight hub in this case) and use the patterns as shown in the screenshots above.

It certainly seems to work for the most part, as I said I’m new to MQTT so haven’t had time / headspace to work out how to try manually configuring the entities.

My guess is that it’s an issue with the sidoh hub, then.
Maybe try to open an issue there?

Any Updates on this one?
i’ve just setup the sidoh hub myself, Generally REALLY happy with it. however, i’ve got the exact same setup mentioned above, and i’m having the same problem.
Cant seem to find the github issue either? did you submit the issue? seems to be that “night_mode” is treated as “OFF” at the sidoh end…but homeassistant treats it as on?? but not 100% here

i tried sending a MQTT command directly (from NodeRed), with
{“state”: “ON”, “effect”: “night_mode”}
and was able to replicate the issue… which made me think i could send
{“state”: “OFF”, “effect”: “night_mode”}
but it unfortunately didn’t work… the light just stays on

Sorry, I haven’t raised it as an issue yet as I wanted to try manually configuring the bulbs in HA rather than MQTT auto discover. Life has overtaken for the last while, so haven’t got that far yet! :slight_smile:

Thanks for the quick response!! All good… I have found a solution to the problem… a little less than ideal, but works for me

the issues is that the light.turn_on service sends the message
{“state”: “ON”, “effect”: “night_mode”}

And its the “state” part that is causing the issue… what i’ve discovered, is that if you just publish the effect by itself and it works! It does mean that HA gets confused with what state the light is in (it thinks its still off)… but in my situation, that doesn’t matter, as 3 minutes later, it turns if off anyway…

This is the action i added into my automation instead of the light.turn_on service call


service: mqtt.publish
data:
payload: ‘{“effect”: “night_mode”}’
qos: ‘2’
topic: milight/:device_id/cct/4

1 Like