Bluetooth presence detector: state ON, light off

Hi,
I have a set of Hue light and I would like them to turn on whenever my phone is in Bluetooth range.
I have been using the following python script : https://gist.github.com/jamesabruce/dbb593a597acb2c0b93b
and in theory, it works the switch associated with the light turns on.

Console outputs: “Blabla state updated to ON”.

However, the light itself does not turn on, the console doesn’t show anything like “Blabla received command ON”

Note that when I trigger the switch manually it does work.

Any tips ?

Show your rules, items and sitemaps otherwaise we only could state that there is an error. Is ist possible to switch the hue with openhab?

Thomas

Thanks for your reply, it’s very simple really:

Rules

rule "Home"
when
Item LSwitch changed from OFF to ON
then
sendCommand(Lights, ON)
end

rule "Away"
when
Item LSwitch changed from ON to OFF
then
sendCommand(Lights, OFF)
end

Items

Group Lights
Group Bedroom

Color Bedroom_Hue “Bedroom Hue” (Bedroom, Lights) {hue=“1”}
Switch LSwitch “Light Switch” (Lights) {hue=“2”}

Sitemaps

sitemap home label=“Test”
{
Frame {
Group item=Lights label=“All lighting” icon="hue"
Group item=Bedroom label=“Bedroom” icon=“bedroom”

}

}

And yes it’s possible. It works well when trigger the switch from my sitemap. The script seems fine as well. I do see the updated state here on http://x.x.x.x:8080/rest/items/LSwitch/state. But sendCommand does not react to it.

Maybe i found something. In your Lights group is one Switch and one Color thias maybe crashes your send command to this group. Did you found any hintes in the openhab logfile?

Thomas

Yes, actually I have realized that the rule file simply doesn’t load… unfortunately I have no idea why.

Where is your bluetooth part of your rule?

Normally you do something like:

rule "Home Bluetooth"
when
Item BluetoothSwitch changed from OFF to ON 
then 
sendCommand(Lights, ON)
end

Actually I fixed it, the problem was that the rules was not loading…
The reason ? A missing “s” in the rules file extension… beginner mistake I guess :joy:

:slight_smile: thats why we are here. And dies the rule now work?