Metadata-Version: 2.1
Name: lifx-lib
Version: 0.9
Summary: A python3 library able to encode/decode Lifx (lan) messages
Home-page: https://github.com/majamassarini/lifx-lib
Author: Maja Massarini
Author-email: maja.massarini@gmail.com
License: MIT
Description: # lifx-lib
        
        [![Build Status](https://travis-ci.com/majamassarini/lifx-lib.svg?branch=master)](https://travis-ci.com/majamassarini/lifx-lib)
        [![codecov](https://codecov.io/gh/majamassarini/lifx-lib/branch/master/graph/badge.svg?token=HQ27JK26MT)](https://codecov.io/gh/majamassarini/lifx-lib)
        [![Documentation Status](https://readthedocs.com/projects/maja-massarini-lifx-lib/badge/?version=latest)](https://maja-massarini-lifx-lib.readthedocs-hosted.com/en/latest/?badge=latest)
        
        A Python 3 library able to encode/decode Lifx (lan) messages.
        
        It can be used with an asynchronous or synchronous client.
        
        ## Examples
        
        ###  Encode
        ```python
            >>> import lifx
            >>> body = lifx.lan.light.SetColor()
            >>> header = lifx.lan.header.make(body.state)
            >>> body.field.color.rgb = (0, 255, 0)
            >>> body.field.color.kelvin = 3500
            >>> body.field.duration = 1024
            >>> msg = lifx.lan.Msg.encode(header, body)
            >>> msg
            [0x31, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0xFF, 0xFF, 0xFF, 0xFE, 0xAC, 0x0D, 0x00, 0x04, 0x00, 0x00]
        ```
        
        ####  Encode from a dictionary
        ```python
           >>> import lifx
           >>> dictionary = {"hue": 335, "saturation": 90, "brightness": 90, "kelvin": 3500, "duration": 1000,
           ...               "transient": True, "period": 180000, "cycles": 30, "skew_ratio": 0.5, "waveform": "sine"}
           >>> body = lifx.lan.light.State_Factory.make("SetWaveform", dictionary)
           >>> header = lifx.lan.header.make(body.state)
           >>> msg = lifx.lan.Msg.encode(header, body)
           >>> msg
           [0x39, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x00, 0x00, 0x01, 0x38, 0xEE, 0x66, 0xE6, 0x66, 0xE6, 0xAC, 0x0D, 0x20, 0xBF, 0x02, 0x00, 0x00, 0x00, 0xF0, 0x41, 0x00, 0x00, 0x01]
        ```
        
        
        ### Decode
        
        ```python
            >>> import lifx
            >>> msg = lifx.lan.Msg.from_bytes([0x58, 0x00, 0x00, 0x54, 0xB9, 0x71, 0x5D, 0x07, 0xD0, 0x73, 0xD5, 0x12, 0x1A, 0xF1, 0x00, 0x00, 0x4C, 0x49, 0x46, 0x58, 0x56, 0x32, 0x00, 0x4D, 0x18, 0x52, 0x42, 0x1E, 0xB5, 0xFC, 0x82, 0x14, 0x6B, 0x00, 0x00, 0x00, 0x71, 0x7E, 0xCC, 0x4C, 0x09, 0x57, 0xAC, 0x0D, 0x00, 0x00, 0xFF, 0xFF, 0x4C, 0x49, 0x46, 0x58, 0x20, 0x42, 0x75, 0x6C, 0x62, 0x20, 0x31, 0x32, 0x31, 0x61, 0x66, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])
            >>> (header, body) = msg.decode()
            >>> header.type
            <State.state_light: 107>
            >>> body.field.color.kelvin
            3500
            >>> body.field.color.rgb
            (61, 87, 86)
            >>> str(body)
            'State {power: 65535, hue: 178, saturation: 30, brightness: 34, kelvin: 3500, rgb: (61, 87, 86), label: LIFX Bulb 121af1}'
        ```
        
        #### Decode to a dictionary
        
        ```python
            >>> import lifx
            >>> msg = lifx.lan.Msg.from_bytes([0x39, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x00, 0x00, 0x01, 0x38, 0xEE, 0x66, 0xE6, 0x66, 0xE6, 0xAC, 0x0D, 0x20, 0xBF, 0x02, 0x00, 0x00, 0x00, 0xF0, 0x41, 0x00, 0x00, 0x01])
            >>> (header, body) = msg.decode()
            >>> header.type
            <State.set_waveform_light: 103>
            >>> factory = lifx.lan.light.Description_Factory()
            >>> s = factory.make(body)
            >>> s[0]
            'SetWaveform'
            >>> s[1]['waveform']
            'sine'
        ```
        
        
        ## Getting Started
        
        ```
        pip install lifx-lib
        ```
        
        ## Diving In
        
        [Documentation](https://maja-massarini-lifx-lib.readthedocs-hosted.com/en/latest/?)
        
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3.8
Classifier: Topic :: Communications
Classifier: Intended Audience :: Developers
Description-Content-Type: text/markdown
