nanoleafapi
pytradfri
nanoleafapi | pytradfri | |
---|---|---|
1 | 6 | |
58 | 935 | |
- | 0.6% | |
2.6 | 9.0 | |
4 months ago | 3 days ago | |
Python | Python | |
MIT License | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
nanoleafapi
-
EO2 -> Nanoleaf palette sync
#requires numpy, pillow #eoPython - https://github.com/tk421storm/eo-python #nanoleafapi - https://github.com/MylesMor/nanoleafapi # # tested in python 3.8 on Win 11 # from urllib.request import urlretrieve from tempfile import gettempdir from os.path import join, splitext, dirname, realpath from uuid import uuid4 from pprint import pprint from time import sleep from eopython import ElectricAccount import numpy as np from nanoleafapi import Nanoleaf, WHITE from PIL import Image nanoleafIP= REPLACE_ME nanoleafAuthToken= REPLACE_ME effect_data = { "command": "add", "version":"2.0", "animName": "EO2", "animType": "plugin", "colorType": "HSB", "pluginUuid": 'ba632d3e-9c2b-4413-a965-510c839b3f71', #https://forum.nanoleaf.me/docs/openapi#_rwyy54qdnrv6 "pluginType": "color", "animData": None, "palette": [ # { # "hue": 0, being a number between 0-360 # "saturation": 100, being a number between 0-100 # "brightness": 100, being a number between 0-100 # }, ], "pluginOptions": [ { "name": "transTime", "value": 100 }, # { useful for some plugins, but doesnt effect currently selected (random) # "name": "linDirection", # "value": "right" # }, { "name": "loop", "value": True }, { "name": "nColorsPerFrame", "value": 2 } ], "brightnessRange": {'minValue':100, 'maxValue':100}, "loop": True } # # thanks to unutbu at https://stackoverflow.com/questions/18801218/build-a-color-palette-from-image-url # def palette(img): """ Return palette in descending order of frequency """ arr = np.asarray(img) palette, index = np.unique(asvoid(arr).ravel(), return_inverse=True) palette = palette.view(arr.dtype).reshape(-1, arr.shape[-1]) count = np.bincount(index) order = np.argsort(count) return palette[order[::-1]] def asvoid(arr): """View the array as dtype np.void (bytes) This collapses ND-arrays to 1D-arrays, so you can perform 1D operations on them. http://stackoverflow.com/a/16216866/190597 (Jaime) http://stackoverflow.com/a/16840350/190597 (Jaime) Warning: >>> asvoid([-0.]) == asvoid([0.]) array([False], dtype=bool) """ arr = np.ascontiguousarray(arr) return arr.view(np.dtype((np.void, arr.dtype.itemsize * arr.shape[-1]))) #log in eoAccount=ElectricAccount(REPLACE_ME_USERNAME, REPLACE_ME_PASSWORD) #get device (from a list, assuming the first) eo2=eoAccount.devices[0] #get the current artwork id currentID=eo2.current_artwork_id() currentURL=eo2.current_artwork_preview() extension=splitext(currentURL.split("?")[0])[1] tempFile=join(gettempdir(), uuid4().hex+extension) print('downloading artwork to '+tempFile) urlretrieve(currentURL, tempFile) img = Image.open(tempFile, 'r').convert('HSV') palette=palette(img) print('found palette with '+str(len(palette))+' colors') #filter found colors based on saturation so we're only getting colors, not white/blacks colorsDesired=10 saturationThreshold=25 luminanceThreshold=50 hueMinDiff=40 filteredPalette=[] storedHues=[] for color in palette: hue=color[0] sat=color[1] val=color[2] if sat>saturationThreshold and val>luminanceThreshold: #also include minimum hue difference check (so we dont end up with a palette of all one color) diffEnough=True for value in storedHues: if hue<=(value+hueMinDiff) and hue>=(value-hueMinDiff): diffEnough=False break if diffEnough: filteredPalette.append(color) storedHues.append(color[0]) if len(filteredPalette)>=colorsDesired: break print('filtered palette to '+str(len(filteredPalette))+' colors') print(filteredPalette) #make effect for nanoleaf for color in filteredPalette: effect_data['palette'].append({'hue':int(color[0]/256)*360), 'saturation':int((color[1]/256)*100), 'brightness':int((color[2]/256)*100)}) effect_name="EO2"#_"+str(currentID) effect_data["animName"]=effect_name #connect to nanoleaf and display effect nano=Nanoleaf(nanoleafIP, nanoleafAuthToken) nano.set_color(WHITE) #response=requests.put(nano.url+"/effects", data = json.dumps({"command":"delete","animName":"EO2"})) #pprint(response.text) pprint(effect_data) nano.write_effect(effect_data) nano.set_effect(effect_name)
pytradfri
-
IKEA Tradfri lamp only
I'm thinking about getting a smart light bulb to my room, but I want to control it from my Raspberry Pi. I checked out LIFX, and it looks great, but a bit too expensive. So, I was looking into buying IKEA's Tradfri bulb, since it costs way less. I found a python API for it, and I can buy a Zigbee module for my Raspberry. Is it possible to use the Tradfri lamp only trough raspberry, without buying any of the controllers from IKEA?
- Investing in lighting did great things for my mental and physical health
-
Can't create identity on my TRÅDFRI gateway
I‘m.not having my decays at hand. I‘d research into https://github.com/home-assistant-libs/pytradfri and try to get it to work.
-
Sending commands to python from shell script.
I see based on this that the -i -m pytradfri sequence looks like it's running some kind of key management code when run in that fashion that won't happen when you import it as a library in a regular Python script.
- Are there any offline/private smart bulb?
-
Managing trädfri bulbs from Linux command line
I guess you can do this with https://github.com/home-assistant-libs/pytradfri ? It's actively maintained at least.
What are some alternatives?
nanoleafMusic - Sync your Nanoleaf lights with Spotify!
openrgb.nvim - Bring RGB to life in Neovim
microk8s - MicroK8s is a small, fast, single-package Kubernetes for developers, IoT and edge. [Moved to: https://github.com/canonical/microk8s]
aioesphomeapi - Python Client for ESPHome native API. Used by Home Assistant.
SaltStack - Software to automate the management and configuration of any infrastructure or application at scale. Get access to the Salt software package repository here:
TRADFRI-Hacking - Hacking IKEA TRÅDFRI products, such as light bulbs, window blinds and other accessories.
eo-python - Electric Objects python library
anonfile-api - An unofficial Python Anonfiles.com API
xled - 🎄Unofficial control for Twinkly - Smart Decoration LED lights.
pylips - Control Philips TVs (2015+) and Ambilight (+ Hue) through their reverse-engineered API (+ MQTT support!)
DoorPi - OpenSource VoIP Door-Intercomstation
docker-reddit-bot-base - :snake: aPRAW base project for building reddit bots in python