Page 2 of 2
Re: Domoticz & OSRAM Lightify
Posted: Tuesday 01 November 2016 14:29
by thorbj
Thanks, I managed to install the script and alter the bulb using the commands in Shell. But when I add the commands on the switch, and press the switch, nothing happens.
I have the following code:
Code: Select all
script:///usr/local/bin/ol --hub 10.10.10.111 --on="A60RGBW 01"
script:///usr/local/bin/ol --hub 10.10.10.111 --off="A60RGBW 01"
It's exactly like your, except from the IP and bulb name.
This code (ol - -hub... etc.) works in Shell, but not when issued from a switch in Domoticz.
What am I missing?
Thanks!
Re: Domoticz & OSRAM Lightify
Posted: Tuesday 01 November 2016 14:37
by fergalom
did you try "/usr/local/bin/ol --hub 10.10.10.111 --on="A60RGBW 01"" in the shell?
Maybe ol is not in /usr/local/bin?
Try "whereis ol" from the shell
Re: Domoticz & OSRAM Lightify
Posted: Tuesday 01 November 2016 14:49
by thorbj
/usr/local/bin/ol --hub 10.10.10.111 --on="A60RGBW 01" don't work from Shell, only ol --hub 10.10.10.111 --on="A60RGBW 01". When I try whereis ol, i get
That's all.
Re: Domoticz & OSRAM Lightify
Posted: Tuesday 01 November 2016 14:57
by fergalom
what directory are you in running ol --hub 10.10.10.111 --on="A60RGBW 01" ?
you might need to change the path to where ol is.
Sounds like its probably:
Code: Select all
pi@raspberrypi ~/Device-Osram-Lightify/bin $ ls
ol
Re: Domoticz & OSRAM Lightify
Posted: Tuesday 01 November 2016 15:24
by thorbj
I found ol here:
Code: Select all
~/.cpan/build/Devices_Osram_Lightify-0.6-iXykqV/bin/ol
But running
Code: Select all
~/.cpan/build/Devices_Osram_Lightify-0.6-iXykqV/bin/ol --hub 10.10.10.111 --off="A60RGBW 01"
from Shell don't work. No such file or directory.
Re: Domoticz & OSRAM Lightify
Posted: Tuesday 01 November 2016 16:49
by thorbj
I removed the cpan module and cloned via Git. But I can't make install.
Code: Select all
pi@DomoCore ~ $ cd Device-Osram-Lightify/
pi@DomoCore ~/Device-Osram-Lightify $ ls
bin examples LICENSE MANIFEST t
ChangeLog lib Makefile.PL README.md
pi@DomoCore ~/Device-Osram-Lightify $ make
make: *** No targets specified and no makefile found. Stop.
pi@DomoCore ~/Device-Osram-Lightify $
Re: Domoticz & OSRAM Lightify
Posted: Tuesday 01 November 2016 17:28
by fergalom
ah ok, you've jogged my memory
Code: Select all
perl Makefile.PL
make
sudo make install
Also I modified ol in bin/ol to include brightness:
Code: Select all
#!/usr/bin/perl
# Sample Usage:
#
# ol --hub=192.168.10.11 --name=hall --sleep=10
#
use strict;
use warnings;
use Device::Osram::Lightify::Hub;
use Getopt::Long;
use Pod::Usage;
#
# The configuration variables
#
my %CONFIG;
#
# Parse the command-line
#
exit
unless (
Getopt::Long::GetOptions( "all-off", \$CONFIG{ 'all-off' },
"all-on", \$CONFIG{ 'all-on' },
"help", \$CONFIG{ 'help' },
"hub=s", \$CONFIG{ 'hub' },
"list", \$CONFIG{ 'list' },
"off=s", \$CONFIG{ 'off' },
"on=s", \$CONFIG{ 'on' },
"fade_on_name=s", \$CONFIG{ 'fade_on_name' },
"sleep=s", \$CONFIG{ 'sleep' },
"brightness=s", \$CONFIG{ 'brightness' },
"name=s", \$CONFIG{ 'name' },
) );
#
# Connect to the hub
#
my $hub = Device::Osram::Lightify::Hub->new( host => $CONFIG{ 'hub' } );
#if ( !$CONFIG{ 'name' } )
#{
# print "Usage: $0 --hub=1.2.3.4 --name=name [--sleep=10]\n";
# print "Missing name parameter - which bulb did you want to fade in?\n";
# exit(0)
#}
# Change Brightness
#
if ( $CONFIG{ 'brightness' } )
{
# Set a light on
foreach my $light ( $hub->lights() )
{
if ( $light->name() eq $CONFIG{ 'name' } )
{
#print("Brightness is $CONFIG{'brightness'}.\n");
$light->set_brightness($CONFIG{'brightness'});
#$light->set_on();
#print("Set $CONFIG{'name'} brightness to $CONFIG{'brightness'}.\n");
exit(0);
}
}
}
#
# Now run the actions
#
if ( $CONFIG{ 'all-on' } )
{
# All on
$hub->all_on();
}
if ( $CONFIG{ 'all-off' } )
{
# ALl off
$hub->all_off();
}
if ( $CONFIG{ 'on' } )
{
# Set a light on
foreach my $light ( $hub->lights() )
{
if ( $light->name() eq $CONFIG{ 'on' } )
{
$light->set_on();
#print("Set $CONFIG{'on'} on.\n");
exit(0);
}
}
}
if ( $CONFIG{ 'off' } )
{
# Set a single light off
foreach my $light ( $hub->lights() )
{
if ( $light->name() eq $CONFIG{ 'off' } )
{
$light->set_off();
#print("Set $CONFIG{'off'} off.\n");
exit(0);
}
}
}
#
# Fade in a light
#
if ( $CONFIG{ 'fade_on_name' } )
{
foreach my $light ( $hub->lights() )
{
if ( $light->name() eq $CONFIG{ 'on' } )
{
my $step = 5;
while ( $step <= 100 )
{
#print "Setting brightness level : $step\n";
$light->set_brightness($step);
$light->set_on();
#print "\tSleeping for $CONFIG{'sleep'} seconds\n";
sleep( $CONFIG{ 'sleep' } );
# Bump brightness
$step += 5;
}
exit(0);
}
}
}
if ( $CONFIG{ 'list' } )
{
foreach my $light ( $hub->lights() )
{
print $light;
}
}
exit 0;
Re: Domoticz & OSRAM Lightify
Posted: Tuesday 01 November 2016 18:29
by thorbj
Thanks, now I successfully installed it via Git.
But I still can't execute the commands from the switch.
I can now run
Code: Select all
~/Device-Osram-Lightify/bin/ol --hub 10.10.10.111 --off="A60RGBW 01"
from Shell to turn off the bulb, but when I press the switch, nothing happens.
This is the log:
Code: Select all
2016-11-01 18:23:11.659 User: Admin initiated a switch command (161/Lightify1/Off)
2016-11-01 18:23:11.660 (Dummy switch) Lighting 1 (Lightify1)
All my other dummy switches works great, but they are triggered by lua scripts. This is the only switch I have that triggers commands like this.
Re: RE: Re: Domoticz & OSRAM Lightify
Posted: Tuesday 01 November 2016 23:05
by fergalom
thorbj wrote:Thanks, now I successfully installed it via Git.
But I still can't execute the commands from the switch.
I can now run
Code: Select all
~/Device-Osram-Lightify/bin/ol --hub 10.10.10.111 --off="A60RGBW 01"
from Shell to turn off the bulb, but when I press the switch, nothing happens.
This is the log:
Code: Select all
2016-11-01 18:23:11.659 User: Admin initiated a switch command (161/Lightify1/Off)
2016-11-01 18:23:11.660 (Dummy switch) Lighting 1 (Lightify1)
All my other dummy switches works great, but they are triggered by lua scripts. This is the only switch I have that triggers commands like this.
Are you using the full path for the switch on/off
Script:///home/pi/Device-Osram-Lightify/bin/ol --hub 10.10.10.111 --off="A60RGBW 01"
Sent from my SM-G930F using Tapatalk
Re: Domoticz & OSRAM Lightify
Posted: Tuesday 01 November 2016 23:13
by thorbj
No

But I tried this now, and it seems thet Domoticz finally tries to run the commands. Yay!
But it returns an error in the log:
Code: Select all
2016-11-01 23:11:17.363 User: Admin initiated a switch command (161/Lightify1/Off)
2016-11-01 23:11:17.364 (Dummy switch) Lighting 1 (Lightify1)
2016-11-01 23:11:18.366 Executing script: /home/pi/Device-Osram-Lightify/bin/ol
2016-11-01 23:11:18.422 Error: Error executing script command (/home/pi/Device-Osram-Lightify/bin/ol). returned: 512
Do you know what this means?
Re: Domoticz & OSRAM Lightify
Posted: Tuesday 08 November 2016 10:37
by thorbj
I've also tried calling perl scripts from the switch, instead of the command itself. This also gives me a 512 error in the log.
I have run chmod +x on the scripts.
bulb_on.pl:
Code: Select all
#!/usr/bin/perl
use Device::Osram::Lightify::Hub;
my $x = Device::Osram::Lightify::Hub->new( host => "10.10.10.111" );
foreach my $light ( $x->lights() ) {
if ( $light->name() eq "A60RGBW 01" ) {
$light->set_on();
exit(0);
}
}
bulb_off.pl:
Code: Select all
#!/usr/bin/perl
use Device::Osram::Lightify::Hub;
my $x = Device::Osram::Lightify::Hub->new( host => "10.10.10.111" );
foreach my $light ( $x->lights() ) {
if ( $light->name() eq "A60RGBW 01" ) {
$light->set_off();
exit(0);
}
}
The command on the switch looks like this:
Code: Select all
script:///home/pi/domoticz/scripts/perl/bulb_on.pl > /dev/null 2>&1 &
script:///home/pi/domoticz/scripts/perl/bulb_off.pl > /dev/null 2<&1 &
This results in the following error:
Code: Select all
Error: Error executing script command (/home/pi/domoticz/scripts/perl/bulb_off.pl). returned: 512
I can't figure out what's wrong here. Am I missing some perl configuration in Domoticz?
Re: Domoticz & OSRAM Lightify
Posted: Tuesday 08 November 2016 22:56
by fergalom
ok so out of interest, I tried your scripts and switch actions above, they work perfectly as expected, no 512
For what its worth, Domoticz v3.5859 and perl v5.14.2
liblightify
Posted: Tuesday 03 January 2017 11:15
by misscat
there is another project with an open source libary on github, working offline (direct contact to the gateway)
It's in C but comes also with an small command line utility
https://github.com/coldtobi/liblightify
misscat
Re: Domoticz & OSRAM Lightify
Posted: Saturday 04 March 2017 12:10
by thorbj
fergalom wrote:ok so out of interest, I tried your scripts and switch actions above, they work perfectly as expected, no 512
For what its worth, Domoticz v3.5859 and perl v5.14.2
I don't know what's going on with my scripts, but I ended up buying a Hue and adding osram bulb to this one, that works great.
Re: Domoticz & OSRAM Lightify
Posted: Thursday 14 September 2017 5:34
by Wob76
Hi,
Just wondering if there is a big advantage to using the hue hub with the Lightify bulbs?
I have been playing around in nodered with the Lightify hub, and I have managed to decode the bulbs and feed them into Domoticz, but it has been very manual, I actually wrote a function to decode the binary protocol, I could continue, I am sure implementing command should be doable, but I am now wondering if it is worth my time.
I did find some node controls, but converting them to nodered could be some work (
https://github.com/rainlake/node-lightify).
Re: Domoticz & OSRAM Lightify
Posted: Friday 15 September 2017 11:47
by thorbj
If you own a hub, or wan't to get a hub anyway, then it's easier to access lightify bulbs in domoticz. But If you can't afford a hub, it would be awesome if there was an easy script/library.