/yeelight-ex

Library for yeelight lamps in Elixir

Primary LanguageElixirMIT LicenseMIT

Yeelight

This is a library to comunicate with yeelight lamps using Elixir.

For discovering the lights it uses a UPnP server that should be started using Discover.start"

# start the discovery server
Yeelight.Discover.start

# Get the device list
devices = Yeelight.Discover.devices

# Send a command
Yeelight.Command.toggle |> Yeelight.Command.send_to(device)

set color flow sequence

color_flow = [
  %Yeelight.FlowExpression.RGB{
    duration: 1000,
    r: 255,
    brightness: 100
  },
  %Yeelight.FlowExpression.RGB{
    duration: 1000,
    g: 255,
    brightness: 100
  },
  %Yeelight.FlowExpression.RGB{
    duration: 1000,
    b: 255,
    brightness: 100
  },
  %Yeelight.FlowExpression.ColorTemperature{
    duration: 1000,
    temperature: 6500,
    brightness: 100
  },
  %Yeelight.FlowExpression.ColorTemperature{
    duration: 1000,
    temperature: 1800,
    brightness: 100
  }
]

Yeelight.Command.start_color_flow(6, 0, color_flow)
|> Yeelight.Command.send_to(hd(devices))

Installation

The package can be installed by adding yeelight to your list of dependencies in mix.exs:

def deps do
  [
    {:yeelight, "~> 0.2.0"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/yeelight.

TODO

  • Finish all possible commands