poinck / lampe

control for your Philips Hue lights from Terminal or Gnome
Creative Commons Zero v1.0 Universal
91 stars 4 forks source link

lampe: support ambient lights, "ct" (color temperature) #43

Closed poinck closed 8 months ago

poinck commented 7 years ago

The bulb with model-ID "LTW001" uses ct to set its color temperature, not a combination of hue and sat

bserem commented 6 years ago

I got myself a bunch of the "white and ambience" lamps from philips. If these are the ones you are referring to in this post I could give some feedback if there is a branch where you work on that!

poinck commented 6 years ago

I will make this my week-goal start working on this feature. (:

poinck commented 6 years ago

@bserem I have branched to "release1.1.11". I let you know when there is something to test.

poinck commented 6 years ago

The last commit adds showing the light-bulb capabilites at info screen (I). You can test it the following way:

./lampe -s 4 I
# or with some debug
DEBUG=1 ./lampe -s 4 I
./lampe -s h # to show meanings of new output

But anyway, more work is needed! For now only the info screen makes use of dynamic capability gathering.

poinck commented 6 years ago

Ah, of course, you will need to install jq on your system; this utility will replace the dependency of "JSON.sh". jq helped me a lot while implementing #44.

bserem commented 6 years ago

The output I am getting is:

bserem@dwarf ~/Development/github/lampe (release1.1.11 *=) $ lampe -s 12 I
 ?  warning, 'JSON.sh' is not installed
 ?  mood_sat=[0..254]        default saturation for
                             mood sequence not set.
                             saturation will not be
                             changed during sequence
    redshift_options="-l 37.98:23.73"
 ?  noise_range=[0..65000]   default 15000, a color
                             between two colors
 ?  noise_interval=[1..]     default 3 seconds
 ?  noise_step=[1..65000]    default 5000, could be
                             more than just one shade
                             of the current color 
 *  You can set these vars in
    ~/.config/lampe/light-defaults

/usr/bin/lampe: line 483: {"state":{"on":true: syntax error: operand expected (error token is "{"state":{"on":true")

I installed jq but not JSON.sh as you can see above.

poinck commented 6 years ago

First, thanks for testing!

Could you run this again in your development-directory with debugging enabled, please? DEBUG=1 ./lampe -s 12 I. I have added ./ to the command to make sure that you are using the version from the branch and not a globally installed older version of lampe.

Do you have light bulbs which are not dimmable in any way (missing the brightness option)?

poinck commented 6 years ago

I realize that I have not replaced every dependency to JSON.sh, yet. Nevertheless, reinstalling it should give you the bulb-capabilities when running ./lampe -s 12 I.

bserem commented 6 years ago
bserem@dwarf ~/Development/github/lampe (release1.1.11 *=) $ DEBUG=1 ./lampe -s 12 I
 ?  mood_sat=[0..254]        default saturation for
                             mood sequence not set.
                             saturation will not be
                             changed during sequence
    redshift_options="-l 37.98:23.73"
 ?  noise_range=[0..65000]   default 15000, a color
                             between two colors
 ?  noise_interval=[1..]     default 3 seconds
 ?  noise_step=[1..65000]    default 5000, could be
                             more than just one shade
                             of the current color 
 *  You can set these vars in
    ~/.config/lampe/light-defaults

[DEBUG] bri: 32
[DEBUG] sat: 192
[DEBUG] hue: 12000
[DEBUG]  ct: 0
 1             L     B  "Floor"
[DEBUG] bri: 254
[DEBUG] sat: 140
[DEBUG] hue: 8418
[DEBUG]  ct: 366
 5             H  HSTB  "Bedroom"
[DEBUG] bri: 172
[DEBUG] sat: 192
[DEBUG] hue: 12000
[DEBUG]  ct: 233
12             H    TB  "Spot 5 2"
[DEBUG] bri: 100
[DEBUG] sat: 192
[DEBUG] hue: 12000
[DEBUG]  ct: 346
16  reachable  H    TB  "Spot 6 2"
./lampe: line 483: {"state":{"on":false: syntax error: operand expected (error token is "{"state":{"on":false")
bserem@dwarf ~/Development/github/lampe (release1.1.11 *=) $ 

1/Floor: plain lamp, no CT or Color 5/Bedroom: Color lamp 12+16/Spots: Ambient spots temperature, no color).

Hope this helps

poinck commented 6 years ago

I have one bulb that is possibly similar to your spots:

"7":{"state":{"on":true,"bri":254,"ct":181,"alert":"none","colormode":"ct","reachable":true},
"type":"Color temperature light","name":"spielzimmer","modelid":"LTW001",
"manufacturername":"Philips","uniqueid":"00:00:00:00:00:00:00:00-00",
"swversion":"0.00.0.00000"},

I will increase debug-output on next commit to hopefully reveal what's different here. You should ommit uniqueid when pasting the output. Additionally I found one typo, but anyway, until now I don't understand why your two spots 12 and 16 have such different behavior.

poinck commented 6 years ago

Commited; referenced wrong issue in commit-message.

bserem commented 6 years ago

Maybe a more complete output helps:

bserem@dwarf ~/Development/github/lampe (release1.1.11 *=) $ DEBUG=1 ./lampe -s I
 ?  mood_sat=[0..254]        default saturation for
                             mood sequence not set.
                             saturation will not be
                             changed during sequence
    redshift_options="-l 37.98:23.73"
 ?  noise_range=[0..65000]   default 15000, a color
                             between two colors
 ?  noise_interval=[1..]     default 3 seconds
 ?  noise_step=[1..65000]    default 5000, could be
                             more than just one shade
                             of the current color 
 *  You can set these vars in
    ~/.config/lampe/light-defaults

[DEBUG] bri: 0
[DEBUG] sat: 192
[DEBUG] hue: 12000
[DEBUG]  ct: 0
 1             L     B  "Floor"
[DEBUG] bri: 254
[DEBUG] sat: 192
[DEBUG] hue: 12000
[DEBUG]  ct: 0
 4  reachable  L     B  "Ceiling"
[DEBUG] bri: 144
[DEBUG] sat: 199
[DEBUG] hue: 7676
[DEBUG]  ct: 443
 5  reachable  H  HSTB  "Bedroom"
[DEBUG] bri: 254
[DEBUG] sat: 192
[DEBUG] hue: 12000
[DEBUG]  ct: 366
 6  reachable  H    TB  "Ceiling2"
[DEBUG] bri: 254
[DEBUG] sat: 192
[DEBUG] hue: 12000
[DEBUG]  ct: 366
 7  reachable  H    TB  "Ceiling3"
[DEBUG] bri: 254
[DEBUG] sat: 192
[DEBUG] hue: 12000
[DEBUG]  ct: 366
 8  reachable  H    TB  "Ceiling1"
[DEBUG] bri: 254
[DEBUG] sat: 192
[DEBUG] hue: 12000
[DEBUG]  ct: 366
 9  reachable  H    TB  "Ceiling4"
[DEBUG] bri: 254
[DEBUG] sat: 192
[DEBUG] hue: 12000
[DEBUG]  ct: 366
10  reachable  H    TB  "Spot 6 1"
[DEBUG] bri: 254
[DEBUG] sat: 192
[DEBUG] hue: 12000
[DEBUG]  ct: 366
11  reachable  H    TB  "Spot 5 3"
[DEBUG] bri: 254
[DEBUG] sat: 192
[DEBUG] hue: 12000
[DEBUG]  ct: 366
12  reachable  H    TB  "Spot 5 2"
[DEBUG] bri: 254
[DEBUG] sat: 192
[DEBUG] hue: 12000
[DEBUG]  ct: 366
13  reachable  H    TB  "Spot 5 1"
[DEBUG] bri: 254
[DEBUG] sat: 192
[DEBUG] hue: 12000
[DEBUG]  ct: 366
14  reachable  H    TB  "Spot 7 2"
[DEBUG] bri: 254
[DEBUG] sat: 192
[DEBUG] hue: 12000
[DEBUG]  ct: 366
15  reachable  H    TB  "Spot 7 1"
[DEBUG] bri: 254
[DEBUG] sat: 192
[DEBUG] hue: 12000
[DEBUG]  ct: 366
16  reachable  H    TB  "Spot 6 2"
./lampe: line 483: {"state":{"on":false: syntax error: operand expected (error token is "{"state":{"on":false")
bserem@dwarf ~/Development/github/lampe (release1.1.11 *=) $ 

I did not omit any lamp in the paste above. All of them are powered.

bserem commented 6 years ago

And here is the dump after I pulled the latest changes:

9b39353 (HEAD -> release1.1.11, origin/release1.1.11) lampe #44: more debug for lightStates
8757722 lampe: fix typo and more debug for lightStates
4913f56 add todo for JSON.sh dependency removal, #43, #44
8c7f9f4 add dependency check for "jq"

And the dump:

bserem@dwarf ~/Development/github/lampe (release1.1.11=) $ DEBUG=1 ./lampe -s I
 ?  mood_sat=[0..254]        default saturation for
                             mood sequence not set.
                             saturation will not be
                             changed during sequence
    redshift_options="-l 37.98:23.73"
 ?  noise_range=[0..65000]   default 15000, a color
                             between two colors
 ?  noise_interval=[1..]     default 3 seconds
 ?  noise_step=[1..65000]    default 5000, could be
                             more than just one shade
                             of the current color 
 *  You can set these vars in
    ~/.config/lampe/light-defaults

[DEBUG] {"1":{"state":{"on":true,"bri":1,"alert":"none","mode":"homeautomation","reachable":false},"swupdate":{"state":"noupdates","lastinstall":"2017-11-28T23:31:10"},"type":"Dimmable light","name":"Floor","modelid":"LWB006","manufacturername":"Philips","productname":"Hue white lamp","capabilities":{"certified":true,"control":{"mindimlevel":5000,"maxlumen":800},"streaming":{"renderer":false,"proxy":false}},"config":{"archetype":"classicbulb","function":"functional","direction":"omnidirectional"},"uniqueid":"00:17:88:01:10:2b:7f:b8-0b","swversion":"5.105.0.21169"},"4":{"state":{"on":true,"bri":254,"alert":"none","mode":"homeautomation","reachable":true},"swupdate":{"state":"noupdates","lastinstall":"2017-11-28T23:31:06"},"type":"Dimmable light","name":"Ceiling","modelid":"LWB006","manufacturername":"Philips","productname":"Hue white lamp","capabilities":{"certified":true,"control":{"mindimlevel":5000,"maxlumen":800},"streaming":{"renderer":false,"proxy":false}},"config":{"archetype":"classicbulb","function":"functional","direction":"omnidirectional"},"uniqueid":"00:17:88:01:10:2b:92:75-0b","swversion":"5.105.0.21169"},"5":{"state":{"on":true,"bri":254,"hue":8418,"sat":140,"effect":"none","xy":[0.4573,0.4100],"ct":366,"alert":"none","colormode":"ct","mode":"homeautomation","reachable":true},"swupdate":{"state":"noupdates","lastinstall":"2017-11-29T15:23:42"},"type":"Extended color light","name":"Bedroom","modelid":"LCT010","manufacturername":"Philips","productname":"Hue color lamp","capabilities":{"certified":true,"control":{"mindimlevel":1000,"maxlumen":806,"colorgamuttype":"C","colorgamut":[[0.6915,0.3083],[0.1700,0.7000],[0.1532,0.0475]],"ct":{"min":153,"max":500}},"streaming":{"renderer":true,"proxy":true}},"config":{"archetype":"sultanbulb","function":"mixed","direction":"omnidirectional"},"uniqueid":"00:17:88:01:02:7a:f8:c0-0b","swversion":"1.29.0_r21169","swconfigid":"6A139B19","productid":"Philips-LCT010-1-A19ECLv4"},"6":{"state":{"on":true,"bri":254,"ct":366,"alert":"none","colormode":"ct","mode":"homeautomation","reachable":true},"swupdate":{"state":"noupdates","lastinstall":"2018-02-05T19:54:59"},"type":"Color temperature light","name":"Ceiling2","modelid":"LTW010","manufacturername":"Philips","productname":"Hue ambiance lamp","capabilities":{"certified":true,"control":{"mindimlevel":1000,"maxlumen":806,"ct":{"min":153,"max":454}},"streaming":{"renderer":false,"proxy":false}},"config":{"archetype":"sultanbulb","function":"functional","direction":"omnidirectional"},"uniqueid":"00:17:88:01:03:7f:70:c4-0b","swversion":"1.29.0_r21169","swconfigid":"AE47C3E4","productid":"Philips-LTW010-1-A19CTv2"},"7":{"state":{"on":true,"bri":254,"ct":366,"alert":"none","colormode":"ct","mode":"homeautomation","reachable":true},"swupdate":{"state":"noupdates","lastinstall":"2018-02-05T19:54:47"},"type":"Color temperature light","name":"Ceiling3","modelid":"LTW010","manufacturername":"Philips","productname":"Hue ambiance lamp","capabilities":{"certified":true,"control":{"mindimlevel":1000,"maxlumen":806,"ct":{"min":153,"max":454}},"streaming":{"renderer":false,"proxy":false}},"config":{"archetype":"sultanbulb","function":"functional","direction":"omnidirectional"},"uniqueid":"00:17:88:01:03:01:55:48-0b","swversion":"1.29.0_r21169","swconfigid":"AE47C3E4","productid":"Philips-LTW010-1-A19CTv2"},"8":{"state":{"on":true,"bri":254,"ct":366,"alert":"none","colormode":"ct","mode":"homeautomation","reachable":true},"swupdate":{"state":"noupdates","lastinstall":"2018-02-05T19:54:42"},"type":"Color temperature light","name":"Ceiling1","modelid":"LTW010","manufacturername":"Philips","productname":"Hue ambiance lamp","capabilities":{"certified":true,"control":{"mindimlevel":1000,"maxlumen":806,"ct":{"min":153,"max":454}},"streaming":{"renderer":false,"proxy":false}},"config":{"archetype":"sultanbulb","function":"functional","direction":"omnidirectional"},"uniqueid":"00:17:88:01:03:02:90:3d-0b","swversion":"1.29.0_r21169","swconfigid":"AE47C3E4","productid":"Philips-LTW010-1-A19CTv2"},"9":{"state":{"on":true,"bri":254,"ct":366,"alert":"none","colormode":"ct","mode":"homeautomation","reachable":true},"swupdate":{"state":"noupdates","lastinstall":"2018-02-05T19:54:54"},"type":"Color temperature light","name":"Ceiling4","modelid":"LTW010","manufacturername":"Philips","productname":"Hue ambiance lamp","capabilities":{"certified":true,"control":{"mindimlevel":1000,"maxlumen":806,"ct":{"min":153,"max":454}},"streaming":{"renderer":false,"proxy":false}},"config":{"archetype":"sultanbulb","function":"functional","direction":"omnidirectional"},"uniqueid":"00:17:88:01:03:03:24:8c-0b","swversion":"1.29.0_r21169","swconfigid":"AE47C3E4","productid":"Philips-LTW010-1-A19CTv2"},"10":{"state":{"on":true,"bri":254,"ct":366,"alert":"none","colormode":"ct","mode":"homeautomation","reachable":true},"swupdate":{"state":"noupdates","lastinstall":"2018-02-13T22:05:36"},"type":"Color temperature light","name":"Spot 6 1","modelid":"LTW013","manufacturername":"Philips","productname":"Hue ambiance spot","capabilities":{"certified":true,"control":{"mindimlevel":1000,"maxlumen":250,"ct":{"min":153,"max":454}},"streaming":{"renderer":false,"proxy":false}},"config":{"archetype":"spotbulb","function":"functional","direction":"downwards"},"uniqueid":"00:17:88:01:02:f0:a7:72-0b","swversion":"1.29.0_r21169","swconfigid":"797DDD7C","productid":"Philips-LTW013-1-GU10CTv1"},"11":{"state":{"on":true,"bri":254,"ct":366,"alert":"none","colormode":"ct","mode":"homeautomation","reachable":true},"swupdate":{"state":"noupdates","lastinstall":"2018-02-13T22:06:21"},"type":"Color temperature light","name":"Spot 5 3","modelid":"LTW013","manufacturername":"Philips","productname":"Hue ambiance spot","capabilities":{"certified":true,"control":{"mindimlevel":1000,"maxlumen":250,"ct":{"min":153,"max":454}},"streaming":{"renderer":false,"proxy":false}},"config":{"archetype":"spotbulb","function":"functional","direction":"downwards"},"uniqueid":"00:17:88:01:03:ae:3f:44-0b","swversion":"1.29.0_r21169","swconfigid":"797DDD7C","productid":"Philips-LTW013-1-GU10CTv1"},"12":{"state":{"on":true,"bri":254,"ct":366,"alert":"none","colormode":"ct","mode":"homeautomation","reachable":true},"swupdate":{"state":"noupdates","lastinstall":"2018-02-13T22:05:17"},"type":"Color temperature light","name":"Spot 5 2","modelid":"LTW013","manufacturername":"Philips","productname":"Hue ambiance spot","capabilities":{"certified":true,"control":{"mindimlevel":1000,"maxlumen":250,"ct":{"min":153,"max":454}},"streaming":{"renderer":false,"proxy":false}},"config":{"archetype":"spotbulb","function":"functional","direction":"downwards"},"uniqueid":"00:17:88:01:02:f0:a1:3d-0b","swversion":"1.29.0_r21169","swconfigid":"797DDD7C","productid":"Philips-LTW013-1-GU10CTv1"},"13":{"state":{"on":true,"bri":254,"ct":366,"alert":"none","colormode":"ct","mode":"homeautomation","reachable":true},"swupdate":{"state":"noupdates","lastinstall":"2018-02-13T22:05:27"},"type":"Color temperature light","name":"Spot 5 1","modelid":"LTW013","manufacturername":"Philips","productname":"Hue ambiance spot","capabilities":{"certified":true,"control":{"mindimlevel":1000,"maxlumen":250,"ct":{"min":153,"max":454}},"streaming":{"renderer":false,"proxy":false}},"config":{"archetype":"spotbulb","function":"functional","direction":"downwards"},"uniqueid":"00:17:88:01:02:f0:a1:41-0b","swversion":"1.29.0_r21169","swconfigid":"797DDD7C","productid":"Philips-LTW013-1-GU10CTv1"},"14":{"state":{"on":true,"bri":254,"ct":366,"alert":"none","colormode":"ct","mode":"homeautomation","reachable":true},"swupdate":{"state":"noupdates","lastinstall":"2018-02-13T22:05:30"},"type":"Color temperature light","name":"Spot 7 2","modelid":"LTW013","manufacturername":"Philips","productname":"Hue ambiance spot","capabilities":{"certified":true,"control":{"mindimlevel":1000,"maxlumen":250,"ct":{"min":153,"max":454}},"streaming":{"renderer":false,"proxy":false}},"config":{"archetype":"spotbulb","function":"functional","direction":"downwards"},"uniqueid":"00:17:88:01:03:ae:30:f1-0b","swversion":"1.29.0_r21169","swconfigid":"797DDD7C","productid":"Philips-LTW013-1-GU10CTv1"},"15":{"state":{"on":true,"bri":254,"ct":366,"alert":"none","colormode":"ct","mode":"homeautomation","reachable":true},"swupdate":{"state":"noupdates","lastinstall":"2018-02-13T22:05:23"},"type":"Color temperature light","name":"Spot 7 1","modelid":"LTW013","manufacturername":"Philips","productname":"Hue ambiance spot","capabilities":{"certified":true,"control":{"mindimlevel":1000,"maxlumen":250,"ct":{"min":153,"max":454}},"streaming":{"renderer":false,"proxy":false}},"config":{"archetype":"spotbulb","function":"functional","direction":"downwards"},"uniqueid":"00:17:88:01:02:f0:a7:77-0b","swversion":"1.29.0_r21169","swconfigid":"797DDD7C","productid":"Philips-LTW013-1-GU10CTv1"},"16":{"state":{"on":true,"bri":254,"ct":366,"alert":"none","colormode":"ct","mode":"homeautomation","reachable":true},"swupdate":{"state":"noupdates","lastinstall":"2018-02-13T22:05:11"},"type":"Color temperature light","name":"Spot 6 2","modelid":"LTW013","manufacturername":"Philips","productname":"Hue ambiance spot","capabilities":{"certified":true,"control":{"mindimlevel":1000,"maxlumen":250,"ct":{"min":153,"max":454}},"streaming":{"renderer":false,"proxy":false}},"config":{"archetype":"spotbulb","function":"functional","direction":"downwards"},"uniqueid":"00:17:88:01:03:ae:38:db-0b","swversion":"1.29.0_r21169","swconfigid":"797DDD7C","productid":"Philips-LTW013-1-GU10CTv1"}}
[DEBUG] bri: 1
[DEBUG] sat: 192
[DEBUG] hue: 12000
[DEBUG]  ct: 0
 1             L     B  "Floor"
[DEBUG] bri: 254
[DEBUG] sat: 192
[DEBUG] hue: 12000
[DEBUG]  ct: 0
 4  reachable  L     B  "Ceiling"
[DEBUG] bri: 254
[DEBUG] sat: 140
[DEBUG] hue: 8418
[DEBUG]  ct: 366
 5  reachable  H  HSTB  "Bedroom"
[DEBUG] bri: 254
[DEBUG] sat: 192
[DEBUG] hue: 12000
[DEBUG]  ct: 366
 6  reachable  H    TB  "Ceiling2"
[DEBUG] bri: 254
[DEBUG] sat: 192
[DEBUG] hue: 12000
[DEBUG]  ct: 366
 7  reachable  H    TB  "Ceiling3"
[DEBUG] bri: 254
[DEBUG] sat: 192
[DEBUG] hue: 12000
[DEBUG]  ct: 366
 8  reachable  H    TB  "Ceiling1"
[DEBUG] bri: 254
[DEBUG] sat: 192
[DEBUG] hue: 12000
[DEBUG]  ct: 366
 9  reachable  H    TB  "Ceiling4"
[DEBUG] bri: 254
[DEBUG] sat: 192
[DEBUG] hue: 12000
[DEBUG]  ct: 366
10  reachable  H    TB  "Spot 6 1"
[DEBUG] bri: 254
[DEBUG] sat: 192
[DEBUG] hue: 12000
[DEBUG]  ct: 366
11  reachable  H    TB  "Spot 5 3"
[DEBUG] bri: 254
[DEBUG] sat: 192
[DEBUG] hue: 12000
[DEBUG]  ct: 366
12  reachable  H    TB  "Spot 5 2"
[DEBUG] bri: 254
[DEBUG] sat: 192
[DEBUG] hue: 12000
[DEBUG]  ct: 366
13  reachable  H    TB  "Spot 5 1"
[DEBUG] bri: 254
[DEBUG] sat: 192
[DEBUG] hue: 12000
[DEBUG]  ct: 366
14  reachable  H    TB  "Spot 7 2"
[DEBUG] bri: 254
[DEBUG] sat: 192
[DEBUG] hue: 12000
[DEBUG]  ct: 366
15  reachable  H    TB  "Spot 7 1"
[DEBUG] bri: 254
[DEBUG] sat: 192
[DEBUG] hue: 12000
[DEBUG]  ct: 366
16  reachable  H    TB  "Spot 6 2"
./lampe: line 483: {"state":{"on":true: syntax error: operand expected (error token is "{"state":{"on":true")
bserem@dwarf ~/Development/github/lampe (release1.1.11=) $ 
poinck commented 6 years ago

Finally, I was able to reproduce this bug and have an idea how to fix it. Maybe you just helped to reduce the codebase. yay

poinck commented 6 years ago

You can check again. I have successfully tested with your "lights.json" output. You will notice that output is slower now, but this will improve with finalizing of issue #44 .

bserem commented 6 years ago

I won't be able to check for the next 10-12 days. Give me time to get back to the hue installation and I'll try it right away.