Ok, deleted all items, groups, rules etc associated with this thread, restarted, (just for fun), and started again…
ITEMS
2 dimmer items and a dummy item to use as a switch to test:
Dimmer GF_LR_HueLight1_Brightness "GF LR Spotlight 1 Dimmer" <light> {channel="hue:blah:brightness"}
Dimmer GF_LR_HueLight1_ColorTemp "GF LR Spotlight 1 Color" <light> {channel="hue:blah:color_temperature"}
Switch vLivingRoomSpots "LR Spot Test"
BASIC RULE TO TEST
Step 1 - Start with ON/OFF to a dimmer item
rule "Living Room Spotlights"
when
Item vLivingRoomSpots received command
then
if(vLivingRoomSpots.state == ON)
{
logInfo(logName,"Living Room Spots Test ON")
GF_LR_HueLight1_Brightness.sendCommand(ON)
}
else
{
logInfo(logName,"Living Room Spots Test OFF")
GF_LR_HueLight1_Brightness.sendCommand(OFF)
}
end
LOG
Turning vLivingRoomSpots ON via sitemap switch
2020-04-26 11:06:56.582 [ome.event.ItemCommandEvent] - Item 'vLivingRoomSpots' received command ON
2020-04-26 11:06:56.597 [vent.ItemStateChangedEvent] - vLivingRoomSpots changed from OFF to ON
2020-04-26 11:06:56.617 [ome.event.ItemCommandEvent] - Item 'GF_LR_HueLight1_Brightness' received command ON
2020-04-26 11:06:56.649 [nt.ItemStatePredictedEvent] - GF_LR_HueLight1_Brightness predicted to become ON
2020-04-26 11:06:56.676 [vent.ItemStateChangedEvent] - GF_LR_HueLight1_Brightness changed from 0 to 100
Turning vLivingRoomSpots OFF via sitemap switch
2020-04-26 11:07:06.303 [ome.event.ItemCommandEvent] - Item 'vLivingRoomSpots' received command OFF
2020-04-26 11:07:06.317 [vent.ItemStateChangedEvent] - vLivingRoomSpots changed from ON to OFF
2020-04-26 11:07:06.331 [ome.event.ItemCommandEvent] - Item 'GF_LR_HueLight1_Brightness' received command OFF
2020-04-26 11:07:06.356 [nt.ItemStatePredictedEvent] - GF_LR_HueLight1_Brightness predicted to become OFF
2020-04-26 11:07:06.374 [vent.ItemStateChangedEvent] - GF_LR_HueLight1_Brightness changed from 100 to 0
So, all looks good there…however…the physical light turned ON fine, (hooray), however it is still on, regardless of the clear OFF command in the logs.
So, thinking about the rule I realised that using the received command
trigger, the Rule will trigger before the Item’s state is updated so it wouldn’t turn off anyway…(correct???)
I changed the rule to ‘received update’ and ‘changed’ just to see what would happen and the light didn’t turn on or off, the logs were also a bit jumbled eg
LOG
2020-04-26 11:14:13.084 [ome.event.ItemCommandEvent] - Item 'vLivingRoomSpots' received command ON
2020-04-26 11:14:13.112 [vent.ItemStateChangedEvent] - vLivingRoomSpots changed from OFF to ON
2020-04-26 11:14:15.684 [ome.event.ItemCommandEvent] - Item 'GF_LR_HueLight1_Brightness' received command ON
2020-04-26 11:14:15.701 [nt.ItemStatePredictedEvent] - GF_LR_HueLight1_Brightness predicted to become 0
So in this case, it ran through the rule, turned the spot ON, but brightness was 0? ie it’s OFF…not what I want either…
Next Step -
I modified the rule so that if vLivingRoomSpots received command as before but it now checks to see if receivedCommand ==ON to correct the received command when:
rule "Living Room Spotlights"
when
Item vLivingRoomSpots received command
then
if(receivedCommand == ON)
{
logInfo(logName,"Living Room Spots Test ON")
GF_LR_HueLight1_Brightness.sendCommand(ON)
}
else
{
logInfo(logName,"Living Room Spots Test OFF")
GF_LR_HueLight1_Brightness.sendCommand(OFF)
}
end
But this got even more confusing, the physical light neither came on or off and the logs showed this:
2020-04-26 11:27:27.535 [ome.event.ItemCommandEvent] - Item 'vLivingRoomSpots' received command ON
2020-04-26 11:27:27.554 [vent.ItemStateChangedEvent] - vLivingRoomSpots changed from OFF to ON
2020-04-26 11:27:27.559 [ome.event.ItemCommandEvent] - Item 'GF_LR_HueLight1_Brightness' received command ON
2020-04-26 11:27:27.580 [nt.ItemStatePredictedEvent] - GF_LR_HueLight1_Brightness predicted to become 0
2020-04-26 11:27:29.908 [vent.ItemStateChangedEvent] - GF_LR_HueLight1_Brightness changed from 0 to 100
2020-04-26 11:27:30.466 [ome.event.ItemCommandEvent] - Item 'vLivingRoomSpots' received command OFF
2020-04-26 11:27:30.538 [ome.event.ItemCommandEvent] - Item 'GF_LR_HueLight1_Brightness' received command OFF
2020-04-26 11:27:30.564 [nt.ItemStatePredictedEvent] - GF_LR_HueLight1_Brightness predicted to become 100
2020-04-26 11:27:30.566 [vent.ItemStateChangedEvent] - vLivingRoomSpots changed from ON to OFF
2020-04-26 11:27:39.936 [vent.ItemStateChangedEvent] - GF_LR_HueLight1_Brightness changed from 100 to 0
All sorts of fun going on there! ON predicting to become 0, (ie off), and the OFF predicted to become 100, (ie ON)…
So, any ideas what is going on here? I’m goiong to go away and change the commands to sending 0 / 100 rather than on / off and see if that makes a difference…next post shortly…