Lightcontrol

I have a more general question how to solve a problem best.
I want my light in the home to be controlled automatically. Today I use cron and astro total radiation to control when to turn light on and off. It is working fairly well.
The problem I want to solve is to be able to use my standard Aeotec Nano Dimmers switches to temporarily increase light when cooking food, or temp disable when watching tv. And so on, scenes.
My problems are:

  1. The dimmers I can not find scene control on. I can get them to send a basic set when pressed. However that becomes a Dimmer Item value change, same as i will get when the dimmer is automatically set. So I would like to be able to catch the explicit basic set. Or of course if there are any smarter solutions.
  2. After changing the light it will be changed back as soon as an automated change is triggered. Is there some smart way to temporarily disable automated tasks for some light sources?
    My normal way of doing this would be with some generic functions and so. But I do understand that rules are better not written that way.

So, any thoughts and pointers in the right direction are appreciated. Both of course around how to more efficiently use the Nano Dimmers and the rule structure itself.

Regards
Tobias

Well, we have 2 database entries for those, depending on their firmware version.

https://www.cd-jackson.com/index.php/zwave/zwave-device-database/zwave-device-list/devicesummary/576

https://www.cd-jackson.com/index.php/zwave/zwave-device-database/zwave-device-list/devicesummary/1096

Likely, the configuration options vary.

See Design Pattern: Manual Trigger Detection. What you need to do is determine whether a change to your Dimmer is caused by OH automation or manually from the device itself. That’s what the DP shows you how to do. Then it’s just a simple matter of setting and checking flags which can either be global variables or Items.

If you use the example, setting dimmers to 100 will disable the automations until their levels are reduced, but there are other options too.

Thanks all!
Will read up and test, will post back with the results.
Amazingly quick help, thanks again.

Finally got around to start working on this.
Apparently there is something I am failing to understand when it comes to groups.
In a rule where I have a “Member of gIndoorLight” trigger the group exists and work.
When I try to do gIndoorLight.members.forEach in a cron triggered rule it cannot be found and I get an error saying “The name ‘gIndoorLight’ cannot be resolved to an item or type”.
What am I missing here?

Thanks

Is the rule written in the rules DSL or scripted automation?

Rules DSL.

Please post your rule.

rule "Automatic"
when
        Time cron "0 * * ? * * *"
then
        logWarn("light", "Automatic executed")
        gIndoorLight?.members.forEach[light |
                var lightName = light.name
                logWarn("light", "Test: " + lightName)
        ]
end

rule "Updated"
when
        Member of gIndoorLight received update
then
        val lightName = triggeringItem.name.split("_").get(0)
        logWarn("light", "Item updated " + lightName + " state: " + triggeringItem.state)
        val levelFromRule = autoLevel.get(lightName)
        if(levelFromRule != null) {
                logWarn("light", "map found: " + levelFromRule)
                manualDelay.put(lightName,  60) //Delay for 60 minutes
        }

end

Please How to use code fences when posting code.

Does this error happen on loading of the .rules file, when the Rule runs for the first time only, or when the Rule runs every time?

Sorry, posted from phone and missed that. Will edit.

Happens every time the rule runs.

Just to eliminate one error that crops up for some users, restart OH. Sometimes, especially immediately after an update, OH fails to recognize a bunch of Items until the next restart. It seems unlikely that that is the case but we can easily rule it out with a restart.

Watch openhab.log for any errors and report them here.

I don’t see anything obviously wrong with the Rule, assuming your “Updated” Rule actually triggers and runs.

The group is created in the UI, so not using an Item file.
So my guess was that the groups are not created because of the way that cron runs or something.

Will restart, but have done that a bunch of times.

This is when automatic is run, no relevant warnings before this:

2019-12-11 21:20:06.842 [WARN ] [eclipse.smarthome.model.script.light] - System started
2019-12-11 21:20:07.625 [WARN] [eclipse.smarthome.model.script.light] - Automatic executed
2019-12-11 21:20:07.627 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'Automatic': The name 'gIndoorLight' cannot be resolved to an item or type; line 36, column 2, length 12

This is when an update happens:

2019-12-11 21:20:45.179 [WARN ] [eclipse.smarthome.model.script.light] - Item updated SpotsFoldingTable state: 26
2019-12-11 21:20:45.189 [WARN] [eclipse.smarthome.model.script.light] - map found: 10

Copy and paste the body of the first rule to the end of the second rule and see what happens when it runs. Something strange is happening here.

Interestingly the same thing happens there.
I have never used groups like this before, so am I missing something?

Maybe. Nothing you have shown so far confirms the existence of a group with that name. Have you actually defined it? Linking an Item to group-name is not sufficient.

1 Like

I do get this in the log, missed that before:

2019-12-11 21:38:43.231 [INFO ] [el.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model 'indoor_light.rules', using it anyway:
There is no context to infer the closure's argument types from. Consider typing the arguments or put the closures into a typed context.

@rossko57 I do get the updates for that group, so I just assumed it was defined.
I added the Items to groups in the UI, visible in the jsondb file.