I'm pretty sure the if is correct, but I'm no expert in lua/perl/bash etc...
I tried changing to a relative path, but still nothing.
The script, perl.lua:
Code: Select all
-- DEVICE INDEX
-- 161 Lightify bulb A60RGBW 01
local OL_BULB_HALL = 161
return {
active = true, -- set to true to activate this script
on = {
OL_BULB_HALL,
},
execute = function(domoticz)
local bulbHall = domoticz.devices[OL_BULB_HALL]
if (bulbHall.state == "Off") then
os.execute('/home/pi/Device-Osram-Lightify/bin/ol --hub 10.10.10.111 --name="A60RGBW 01" --Off')
print("Lys gang av")
end
if (bulbHall.state == "On") then
os.execute('/home/pi/Device-Osram-Lightify/bin/ol --hub 10.10.10.111 --name="A60RGBW 01" --On')
print("Lys gang på")
end
end
}
Also it runs twice:
Code: Select all
2016-11-02 13:35:41.105 User: Admin initiated a switch command (161/Lightify1/Off)
2016-11-02 13:35:41.225 LUA: Handling events for: "Lightify1", value: "Off"
2016-11-02 13:35:41.225 LUA: =====================================================
2016-11-02 13:35:41.225 LUA: >>> Handler: perl
2016-11-02 13:35:41.225 LUA: >>> Device: "Lightify1" Index: 161
2016-11-02 13:35:41.225 LUA: .....................................................
2016-11-02 13:35:41.263 LUA: Lys gang av
2016-11-02 13:35:41.263 LUA: .....................................................
2016-11-02 13:35:41.264 LUA: <<< Done
2016-11-02 13:35:41.264 LUA: -----------------------------------------------------
2016-11-02 13:35:41.264 LUA: =====================================================
2016-11-02 13:35:41.264 LUA: >>> Handler: perl
2016-11-02 13:35:41.264 LUA: >>> Device: "Lightify1" Index: 161
2016-11-02 13:35:41.264 LUA: .....................................................
2016-11-02 13:35:41.312 LUA: Lys gang av
2016-11-02 13:35:41.312 LUA: .....................................................
2016-11-02 13:35:41.312 LUA: <<< Done
2016-11-02 13:35:41.312 LUA: -----------------------------------------------------
2016-11-02 13:35:41.106 (Dummy switch) Lighting 1 (Lightify1)
EDIT:
I've also made two perl scripts called bulb_off.pl and bulb_on.pl, and two bash scripts called lightify_bulb_on.sh, and lightify_bulb_off.sh. The bash scripts simply calls the perl scripts. They all work in shell.
I tried calling these scripts, both perl and bash, in the lua script instead of the ol --hub.... command. But no result here either.
Perl script 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);
}
}
Bash script lightify_bulb_on.sh:
Code: Select all
#!/bin/bash
#!/usr/bin/perl
#!/home/pi/Device-Osram-Lightify/bin/ol
perl /home/pi/domoticz/scripts/perl/bulb_on.pl > /dev/null 2>&1 &
echo "lightify_bulb_on finished"; > /dev/null 2>&1 &
As a side note, I have tried running these scripts directly form the switch, this results in a 512 error. Maybe because of perl?