LIFX call flame effect from within HA

Just define a rest_command in your configuration.yaml. Example:

rest_command:
  flame:
    url: https://api.lifx.com/v1/lights/YOUR_SELECTOR/effects/flame/
    method: POST
    headers:
      authorization: Bearer YOUR_LIFX_TOKEN
      accept_encoding: 'gzip, deflate'
    content_type: 'application/json'
    payload:  '{"power_on": false}'

in YOUR_SELECTOR you should write the selector of the light/lights you want to run the effect on. Selector is the equivalent to entity_id in HA. Example:

    url: https://api.lifx.com/v1/lights/8w8sadsk213/effects/flame/

if you want to run the same effect in more than one light within the same call, they must go comma separated. Example:

    url: https://api.lifx.com/v1/lights/8w8sadsk213,3klmrlfd021/effects/flame/

In YOUR_LIFX_TOKEN you must put your lifx token :).

In order to call the effect in automations/scripts:

  - service: rest_command.flame

In the payload section you can toy around with the parameters: period, duration, power_on and fast. All the information can be found in the LIFX HTTP API documentation:

1 Like

IS this possible to do locally?

i.e. without including lights in the Lifx cloud.


it is, it goes way beyond my knownledge though.If you get it to work, let me know please :slight_smile:
1 Like

There’s node-red-contrib-node-lifx which (like Home Assistant) communicates via LIFX’s LAN protocol.

This node supports waveforms which is the basis of all effects.

Does the flame effect work with single lights?

Looking at the public protocol it appears to only be for the Tile type lights

  TileEffectType:
    type: uint8
    values:
      - name: "TILE_EFFECT_TYPE_OFF"
        value: 0
      - name: reserved
        value: 1
      - name: "TILE_EFFECT_TYPE_MORPH"
        value: 2
      - name: "TILE_EFFECT_TYPE_FLAME"
        value: 3
      - name: reserved
        value: 4

hey thanks but does this node perform the exact morph/flame effects from LIFX?

I run it in a candle, never tried on tile

Because it supports the API’s waveform feature, it can do any effect you want. The challenge is to configure a waveform so that it performs an existing effect like flame. The API documentation doesn’t offer any examples on how to do that.

As for flame and morph, apparently those are firmware effects baked into certain types of LIFX products.

I’d love to be able to use the LAN protocol from LIFX but I don’t even know where to start. I’m barely using YAML. Could you tell me where to learn?

LIFX’s LAN protocol defines how data should be packaged within a UDP packet. The easiest way to experiment with it is to use the Node-Red node I described above. If you’re unfamiliar with Node-Red, this is a perfect opportunity to learn it.


EDIT
The other option is to use Linux’s netcat command to send UDP packets. The challenge will be to learn how to piece together the LIFX commands that must sent to the LIFX bulb.

1 Like