Beware : Legrand is moving their API to the Netatmo one, the last version of these script reflects this change
Controls lights in a Legrand Home+Control installation in a quick and dirty way.
It has been tested on linux and android using Termux. My only goal was to control my lights through my PinePhone (without installing Anbox) and since it has been acheived for me, here is source (with no warranty whether you can use it).
This software relies on python3. Install it and if necessaries dependencies through pip.
Configuration is stored in ~/.config/LightControl
.
You should have an account on https://dev.netatmo.com and register your app to get a client_id
and client_secret
.
Copy app_data.json
in the configuration directory and fill the fields with information sent by Legrand on subscription, namely client_id
, client_secret
and subscription_key
.
When first using lc.py
it should login and retreive the topology. A new login can be done by removing the token.json
file in config directory. Topology can be retreived using '-g', printed using '-p' and written using '-w'.
Once everything is set-up, you can execute the text ui by launching lc.py
.
It will print out your lights and their status and give you a command line :
Room1
a - Light1
b - Variator1 (100)
c # Light2
Room2
d - Light3
e - Variator2 (40)
cmd>
Each light has a letter in front.
- to toggle lights, simply enter the letters you want to toggle (eg: "bcd") and presse Enter
- to change the value of a variator, enter the letter in uppercase followed by the value you want to set (eg: "B10" to set Variator1 intensity to 10%)
- to refresh write a non-alpha character
- to quit simply press Enter (empty command)
LC can be used in a non-interactive way, the lights to toggle be passed on the commandline, there is also a '-s' commutator to get the status of the lights (without prompt), use '-t' to just print the tree with the letters (no request is performed).
sxmo_lc.sh
is a wrapper for LightControl
to be used with SXMO, which is a menu driven interface for phones on top of mobile linux. You can easily use it on PostmarketOS, see Postmarketos wiki to learn how to install and use it.
By default you can use it from the source directory. If you want to move the files, you can set the Lc
variable (either inside or outside the script) to point towards the lc.py
program.