Complex LIFX behaviors via simple text scripts

Finally, I can create my own light shows for my LIFX bulbs without a phone app and without the cloud. And, I can run the scripts from HA, easily.

About the only credit I can take for this project is that I stumbled onto bardolph. Until this post there has been no mention of it in this community.

The LIFX app is needed to configure new bulbs. It works well, and can perform interesting effects. But, it uses the cloud, works its own way, and I don’t think it can be scripted. For those who want to control their bulbs locally, LIFX gave us the LIFX Lan protocol. It works well, but is definitely not for the feint of heart.

Enter M. L. Clark. He contributed lifxlan, the Python library for accessing LIFX devices locally using the official LIFX LAN protocol. It is comprehensive, and widely used, but still a bit much for my mediocre Python skills.

I looked at a number of facilities built with lifxlan. However, bardolph, grabbed my attention. It promised to reduce the control of LIFX bulbs to a matter of simple text script files. So, I tried it, and it seems to work as advertised. Thank you Al Fontes, Jr.

I run HASSIO in docker on Raspbian on a Pi4B. So, I installed bardolph in Raspbian. Simple, no problems. My testing and scripting also proceeded easily. So, I started looking for a way to integrate bardolph with HASSIO. The LIFX component works for basic bulb control, but doesn’t match the speed or flexibility of bardolph.

HASSIO won’t allow “pip install”, and the Python script component won’t allow “includes”, so I’m looking at custom components and Apdaemon. If anyone could help me with either of those approaches I will be grateful.

So, for now (and maybe the foreseeable future) my integration is via this shell script:
lsrun: ‘ssh -i /config/sshroot/id_rsa -o StrictHostKeyChecking=no -q [email protected] lsrun /usr/share/hassio/share/bardolph/scripts/{{ ls_script }}.ls’
This works fine and allows the script name to be specified in the shell-command service call. My public and private keys live in /config/sshroot on hassio and were specified to Raspbian via ssh-copy-id (core-ssh:/config/sshroot# ssh-copy-id -f -i id_rsa.pub [email protected]). I put my ls scripts in /share/bardolph/scripts/ using the samba add-on to hassio. That directory is reached in Raspbian as in the shell script.

Regarding custom components, I’ve specified bardolph and its dependencies in a manifest and successfully loaded it. But I don’t know how to invoke the loaded .py files. Maybe you do?

If you don’t run Raspbian, you can implement bardolph on a Raspberry Pi 0W for a shade over $10 and adapt the shell-script accordingly (maybe use the -s option of lsrun).

That’s it for now.

I moved your post to the Development category as you are asking questions about developing a custom component. I then re-read it and there is a case to be made for leaving it in Share you r projects. Let me know if you want it moved back.

There are a couple of Discord channels that may help:

Developers General: https://discord.gg/fjMdQR
Custom Components: https://discord.gg/yZuJP7

I have a number of Lifx lights and am following with interest.

Hi Tom.

I would prefer “projects”. I may or may not get help, but mostly wanted to let people know about bardolph. Thanks for your efforts and concern. HNY.

No problem. Done.

Can you elaborate, what does Bardolph provide that Home Assistant does not? At least the examples on the frontpage are easily implemented with HA scripts, here are a few of my own:

script:
  wakeup_light:
    sequence:
      - service: light.turn_on
        entity_id: light.bedroom
        data:
          kelvin: 5500
          brightness_pct: 90
          transition: 1200
  night_light:
    sequence:
      - service: light.turn_on
        entity_id: light.bedroom
        data:
          hs_color: [0, 100]
          brightness_pct: 8

Please read the bardolph documentation, especially Lightbulb Script Reference. Your examples are simple bulb control. Yes, HA does that perfectly well, and yes, the bardolph home page example scripts are simplistic. Try fading different lights on and off at different rates with different HSBKs 25 times in 10 seconds. Try a marching light display. You used five lines of yaml to turn on a light. A bardolph script could do the same in one line. The distinctions are complex light behaviors and simple text scripts. I don’t suggest that you install bardolph to fade on a single light.

1 Like

I’ve created a custom_component to implement the Bardolph script engine in HASS. This should work in any installation of HA, not just the Raspbian approach I had previously described. See https://github.com/JAAlperin/hass-bardolph. Let me know what you think.

1 Like