Rule 3.0: Time, Variable Math and Logic

Perfect, thanks again. Happy Holidays!

the release notes say that fade dimmer allows a variable to be set for time, but I’m not seeing that as an option. am I missing something? I’m using .119

Use %variable-name%

I'm trying to insert an Hour:Minute timestamp into a global variable so that I can display it on a dashboard tile.

Basically, I want to be able to accomplish "When mailbox is open, set mailbox status variable to 'Mail delivered at 13:45.'"

In other words %Mailbox-Status%= "Mail delivered at %Timestamp%."

RULE 1 ) has three actions:

  1. Defines local variable %Hour% as current hour (number)
  2. Defines local variable %Minute% as current minute (number)
  3. Defines global variable %Timestamp% as %Hour%:%Minute% (string)

Steps 1 and 2 of the rule work as expected. I can't seem to get #3 to work. I've tried a couple different iterations of changing variable types, but no results.

RULE 2) The rule that detects motion and sets the %Mailbox-Status% (string) variable works fine (without any time information as I haven't gotten that working quite yet.)

Eventually I would combine these into one rule, but I have them separate for now.

I guess to sum up, I want to take two local variables, insert them into a global variable, and separate them with a colon. Is this possible?

Unless I'm missing something couldn't you just use the pre-defined variable %time% ? Is that not available in RM 3? I have only used RM 4.

Not in 3.0, that is no longer developed. In 4.0 it should be possible.

Welp. Yeah, that made things a whole hell of a lot simpler. Thanks, @JNS!

Is there a list somewhere of all the pre-defined variables? I didn't realize that was a thing.

1 Like

If you are running RM 4 you probably should have posted this under a RM 4 thread.

They are mentioned in this post

The variables I am aware of are %device%, %value%, %time%, %date%,

@bravenel im trying to use this but am hitting a wall
i have a global variable caller %LR Temp% and i want to subtract 1.5 from it can you help advise.
ive trided
%LR Temp% -1.5
%LR Temp% %-1.5%
%LR Temp% %-%1.5

You need to use Variable Math:

Thanks didnt realise i would have to declare it as another variable. Was trying to do the math in the setheatpoint command

The only way to do math is with variables.

Can you please elaborate? There doesn't appear to be a section in Documentation that explains Variable Math and "% remainder" doesn't make sense to me.

My assumption is that 'variable % constant' = 'variable * 0.constant'

but maybe I'm wrong?

% is the mod (modulus) operator. If you divide 22 by 4, grade school style, the answer is 5 with a remainder of 2. 22 mod 4 is 2.

Um, Bruce, 22 = 5 x 4 + 2.

4 x 4 = 16.

Haha, yeah.... slow Saturday morning!

Anyway, 18 mod 4 and 22 mod 4 are both 2

1 Like

Got it, thanks.

Download the Hubitat app