How to switch a light based on (Neo Coolcam) luminance value?

Some usefull background info:

  • Hardware: RPI4, Neo coolcam PIR, Neo coolcam wall plug, Aeotec z-stick gen5
  • openHAB version: 3.3.0
  • Installed the latest z-wave binding like described in this thread as my device was not supported with the “default” z-wave binding of OH3.3.0

I want to switch my light on when the luminance is below a certain value. I tried to do this with rules as to my understandings this is the way to go.

Rule configurations i tried (configured via GUI) are:

triggers:
  - id: "1"
    configuration:
      itemName: CoolcamPIR1_Sensorluminance
      command: COMMAND_CLASS_SENSOR_MULTILEVEL
    type: core.ItemCommandTrigger
conditions:
  - inputs: {}
    id: "3"
    configuration:
      itemName: CoolcamPIR1_Sensorluminance
      state: "100"
      operator: <=
    type: core.ItemStateCondition
actions:
  - inputs: {}
    id: "2"
    configuration:
      command: ON
      itemName: CoolcamWallPlug1_Switch
    type: core.ItemCommandAction
triggers:
  - id: "1"
    configuration:
      itemName: CoolcamPIR1_Sensorluminance
    type: core.ItemStateUpdateTrigger
conditions:
  - inputs: {}
    id: "3"
    configuration:
      itemName: CoolcamPIR1_Sensorluminance
      state: "100"
      operator: <=
    type: core.ItemStateCondition
actions:
  - inputs: {}
    id: "2"
    configuration:
      command: ON
      itemName: CoolcamWallPlug1_Switch
    type: core.ItemCommandAction
configuration: {}
triggers:
  - id: "1"
    configuration:
      itemName: CoolcamPIR1_Sensorluminance
      state: ">= 100"
    type: core.ItemStateUpdateTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      command: ON
      itemName: CoolcamWallPlug1_Switch
    type: core.ItemCommandAction

None of them worked. I also tried ugly solutions with a cron but that did also not work. I can see that i reveive luminance updates. The value is updated in the gui and i see this in the logs:

What i’m doing wrong?
Thanks for the help in advance!

Thanks for posting full rule in a useful way :smiley:

Do you have an Item of this name?

What happens to that Item in your events.log?

I think it is very unlikely this Item receives a command at all. An openHAB Item command is a “do something” instruction, and you don’t send instructions to sensors.

Command in this context (Item) has nothing to do with any zwave transactions referring to command.

Even if the Item did receive a command, I really don’t think it would be the zwave class name.

I think what you are looking fo is a change to your luminance Item state.

Once you have figured out what event to use as a trigger, then you’ll need to think about that state. Find out (your events.log again) exactly what that state is.
50 lx is not the same as 50 bananas or even just 50.
It follows you can’t successfully compare 50 lx with 50 bananas or even just 50.
If your Item state is in lx units, so will your comparison need to be

2 Likes

Thanks for your reply.a

  • Yes i have an item with the name `CoolcamPIR1_Sendorluminance.
  • This happens in the event.log when the luminance value changes:

I got the “command” from the logs, added to my original post but it seems not to work like that…

As you can see in the snippit from my event.log i think the value is just nummeric/point no lx or something. I’m not sure if operators like < or <= are supported. Based on the event.log i would say something like this must work:

configuration: {}
triggers:
  - id: "4"
    configuration:
      state: ">= 100"
      itemName: CoolcamPIR1_Sensorluminance
    type: core.ItemStateChangeTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      command: OFF
      itemName: CoolcamWallPlug1_Switch
    type: core.ItemCommandAction

but unfortunately it doesn’t, any idea?

I tend to agree that your luminance is dimensionless. Please check the luminance channel of your device:

I think you would have to use a ‘When … changed’ luminance trigger and either
check within a script whether the luminance is above/below your threshold


or to use a “But only if” condition:


configuration: {}
triggers:
  - id: "1"
    configuration:
      itemName: ZWaveNode061NASPD07ZNEOCoolcamPIR5in1_Sensorluminance
    type: core.ItemStateChangeTrigger
conditions:
  - inputs: {}
    id: "3"
    configuration:
      itemName: ZWaveNode061NASPD07ZNEOCoolcamPIR5in1_Sensorluminance
      state: "30"
      operator: ">="
    type: core.ItemStateCondition
actions:
  - inputs: {}
    id: "2"
    configuration:
      itemName: ZWaveNode0065046xxDimmerInsertButton
      command: OFF
    type: core.ItemCommandAction

Both approaches work for me.

1 Like

I’m surprised for a zwave channel, but that is the point of finding out exactly what we are dealing with.

Yes and no; importantly, not in a rule trigger. You can trigger if state changes to XX, but not state change to >XX

That’s okay, as @Ap15e suggests, you can trigger on any change (or update) and then do a “greater/less than” comparison in a condition section.

So from your first post. this looks right

trigger - condition - action

Thanks, I got it working now. I have no idea why its working now and not before. Thanks for the support (to all).

1 Like