Wifi Smart Bulbs

Last new years eve we visited a couple of friends who just had moved into a house. The house had no smart house installation, but my friend had installed RGB spots instead of the normal whites in the combined living/dining room. When we arrived he put them into “party mode” which made the bulbs fade through the colors giving a nice atmosphere in the room. Ever since that night my wife have been bugging me to get dimmable and/or RGB bulbs, and around Black Friday I bulged and bought 6 Nedis RGB wifi bulbs (WIFILC10WTE14).

The bulbs were chosen because I had seen there was an existing integration with Home Assistant(HA) called Tuya, and they were fairly priced. When they arrived I connected the bulbs through the Smart-life app and the Tuya integration worked out of the box and the bulbs appeared in HA straight away. Controlling the bulbs via HA was easy, and even with Node Red I was able to make the bulbs do what I wanted (almost – keep reading).

I installed 3 bulbs in our bedroom and 3 in my daughter’s room and wanted to make the IHC buttons in the rooms control the bulbs. The rooms only have one outlet in the ceiling, but there is two buttons because of the layout. I made a plan of what I wanted the buttons to do – which turned out to be different in each of the rooms. In the bedroom I wanted to be able to dim the light, and change the color of the bulbs, and in the other room I wanted to switch between bright white and party mode.

The easiest room was the daughters room – I just had to decide how I wanted the buttons to be programmed. My daugther was already accustomed to just pressing one of the buttons and then the light would toggle, and this should not change. So the solution became that a short press should toggle the light, and a long press should switch between white and party mode. To achieve this there was two solutions – add an KIP component on the IHC controller and make that decide if a button had been pressed for a short or long time, or build some logic in Node Red to identify the length of a press. The decision fell on making everything in Node Red – this reduces the changes required to be made to the IHC Controller, but it is also way easier to change on the go than flashing the controller each time.

The solution currently deployed is not pretty (who has time for that anyway) because I experienced a few issues with the bulbs. First of all the bulbs was slow as fuck – press the button and it would toggle after 1+ seconds. Second of all I had three bulbs and the HA integration called each bulb sequentially so if I pressed the button several times in a row, the state of the bulbs was undeterministic – some might be on, others not, but I could be sure that they most certainly would not be in the same state, and that they would not turn on the same time. Then it occurred to me that the bulbs would not work if the internet connection was down, or the service was down. And then there was the side effect of my house being under surveillance of who ever hosted the api for the bulbs.

It turned out that I was not the only one with these problems and they have made a tool: Tuya-convert that is able to flash the bulbs with Tasmota. Tasmota is a firmware that runs on ESP8266 devices and provides a web interface and MQTT support and is built for various IOT devices. Tasmota can be configured with templates, and someone else already figured out the configuration needed for the Nedis bulbs: https://templates.blakadder.com/nedis_WIFILC10WTE14.html – but besides PwmFrequency 100 and SetOption37 1, I had to run setoption17 1 and setoption59 1.

Switching to Tasmota made the bulbs answer nearly instantaneously, but I had to reconfigure HA with a custom configuration as for some reason I have not figured out yet, the bulbs will not work when configured to only one white channel, but the following HA configuration works as a workaround for that.

  - platform: mqtt
    name: "Bulb 3"
    command_topic: "cmnd/bulb3/POWER"
    state_topic: "tele/bulb3/STATE"
    state_value_template: "{{value_json.POWER}}"
    availability_topic: "tele/bulb3/LWT"
    brightness_command_topic: "cmnd/bulb3/Dimmer"
    brightness_state_topic: "tele/bulb3/STATE"
    brightness_scale: 100
    on_command_type: "brightness"
    brightness_value_template: "{{value_json.Dimmer}}"
    rgb_command_topic: "cmnd/bulb3/Color2"
    rgb_state_topic: "tele/bulb3/STATE"
    rgb_value_template: "{{value_json.Color.split(',')[0:3]|join(',')}}"
    rgb_command_template: "{% if red == 255 and green == 255 and blue == 255 %}0,0,0,0,255{% else %}{{red}},{{green}},{{blue}},0,0{% endif %}"
    effect_command_topic: "cmnd/bulb3/Scheme"
    effect_state_topic: "tele/bulb3/STATE"
    effect_value_template: "{{value_json.Scheme}}"
    effect_list:
      - 0
      - 1
      - 2
      - 3
      - 4
    payload_on: "ON"
    payload_off: "OFF"
    payload_available: "Online"
    payload_not_available: "Offline"
    qos: 1
    retain: false

This post became much longer than intended, and not covering all the parts I wanted it to, but then there will be another covering how to identify the button press length in Node Red.

Happy hacking, and happy new years!

Leave a Comment