Autowarm (CLOSED)

hi everyone im trying to transferer my rules created in paperui experimental engine to text based rules

my rule isnt working my ruke is

rule "Test LRLamp 20%@12:03PM Daily"
when
Time cron "	0 3 0 1/1 * ? *"
then
if (Lamp1_Brightness >= 20) {
sendCommand(Lamp1_Brightness, 20)
}
end

when this rule runs the log:tail command returns error

00:03:00.059 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule Test LRLamp 20%@10PM Daily: An error occurred during the script execution: The name '<XFeatureCallImplCustom> >= <XNumberLiteralImpl>' cannot be resolved to an item or type.

Sounds like it couldn’t find your Lamp1_Brightness item. You could try checking the items in Karaf, or log the state before the IF in your rule…

Your rule is error because Lamp1_Brightness is an item. You must do that :

rule “Test LRLamp 12:03PM Daily”
when
Time cron " 0 3 0 1/1 * ? *"
then
if ((Lamp1_Brightness.state as DecimalType).intValue >= 20) {
sendCommand(Lamp1_Brightness, 20)
}
end

Is Brightness really Decimal … I think PercentType is correct…

I think this isn’t needed … I think this would be work too:

rule "Test LRLamp 12:03PM Daily"
when
  Time cron "0 3 0 1/1 * ? *"
then
  if (Lamp1_Brightness.state >= 20) {
    Lamp1_Brightness.sendCommand(20)
  }
end
1 Like

im still pretty new too all the text based stuff so its hard to understand i might aswell learn french lol thanks everyone for your help

could you please explain why you made the changes to the origianal code and why it wasent working and why it now would

To Access the State of any Item you must describe it in rule. → item.state not only item

the .state was missing then i will try now and get back too you

1 Like
rule "Test KL 1:20PM Daily"
when
  Time cron "0 22 13 1/1 * ? *"
then
  if (BULB1DSKITCHEN_Brightness.state >= 20) {
    BULB1DSKITCHEN_Brightness.sendCommand(20)
  }
end

this rule worked thanks for that i only made changes to the cron so it would run now and changed also changed bulb as people were using lamp 1

is there a way to slowly fade the light from 100 to 10 over an hour or so period ?

Maybe you can get some hints from this thread?

iv just looked throught there i will read it again see if i can make sense of it i was hoping for a simple command

like decrease brightness of lamp by -5 run by a cron time nothings ever simple lol

ok i have got my rule running the rule is still

rule "Dim LR Light @ 10:00PM Daily"
when
  Time cron "	0 0 22 1/1 * ? *"
then
  if (Lamp1_Brightness.state >= 20) {
    Lamp1_Brightness.sendCommand(20)
  }
end

could someone tell me how to add a only if to my rule i need the rule to run as long as Movie Mode is not Enabled

my movie mode trigger is called

Movie_Mode_Trigger changed from NULL to ON
rule "Dim LR Light @ 10:00PM Daily"
when
  Time cron "	0 0 22 1/1 * ? *"
then
if (Movie_Mode_Trigger.state == OFF) {
  if (Lamp1_Brightness.state >= 20) {
    Lamp1_Brightness.sendCommand(20)
  }
}
end
1 Like

Thanks for that i will add it into my rule now

i was recomended a text editior too help with creating rules with OH cant remember what its called any ideas ?

just found that myself waiting for install i just didnt think the one i was recomended was called that

https://docs.openhab.org/configuration/editors.html

Here are all listed :slight_smile:

what editor would you recomend

do you after enable the openhab eextension or set it as a default in studio code i have pasted a rule and its just white text not colored i have downloaded and installed the OH extention

Works when opening a rule thanks

I don’t know …

I use Atom on my Macbook…

There is no Packages especially for Openhab… but rule code is JavaScript …