In my bedroom, my wife and I each have a SmartThings button that we use to control our bedside lamps plugged into a Zwave plug. These buttons also report temperatures. So in my "master bedroom" dashboard, I currently see 2 different temperatures. They're usually pretty close together, so I don't really care to much except I want to use this as a learning exercise to become a little more familiar with my Hubitat. I haven't had much of a chance to do anything more than add a few very simple lighting rules.
I've played around with it and nearly got it figured out. I created a virtual temperature sensor and named it "Master Bed Avg Temp". I went to RM and created a rule. I created a local variable called AvgTemp. I set the trigger condition to be when Button1 or Button2 reports a temperature change.
What I can't figure out is how to set my variable to be an average of the 2. And then how do I set the temperature of the virtual temperature sensor to be that of the variable?
I created the app a looooooong time ago (more than 2 years)
This was when RM was fairly basic so it was easier to create the app.
But to be honest, most people will tell you for some things (inc this) a little app can be quicker.
That takes me to a login page and if you try to register, it says
**** Please note:
Although this site is open for user registration, it will be a number of weeks before it is complete and you are able to login.
Please be patient, you will receive a mail once the site is open with your login details (It will be worth the wait!)
I had already tried creating variables for this. But in RM, I don't see a way to set a variable using any type of complex math. I'm sure there is a way, but it's not obvious to me. I can select the two variables and then I just have a dropdown menu of what I can do.
I only mentioned @Cobra's app because I believe in using what is there than re-inventing the wheel.
I don't see a purpose for installing an app when I should be able to do this with a single line of code. I don't like the fact that I have to create an account to access his site without even knowing what's there. I use a password manager, but I don't like creating accounts that I don't need.
This is what my entire rule looks like currently. It works. If I go to devices and manually set the temperature value of the virtual device to something other than 0 and then run the actions, it sets the two temperature values to the current temperature and changes the temperature of the virtual device to 0.
I just can't figure out how to actually get the average of the two variables stored in a 3rd variable.
It’s free and always will be.
The contents are hidden because I want to be able to restrict who has access to the code and ideas.
If you knew my history, then you would understand why I have done this.
It is cumbersome to enter, but possible in a couple action steps. You need one action step to add the two variables. (One of your above posts indicates that you figured out how to do that.) Then, you need another action step to divide the result by two. It looks like you can use a variable within an action to set the same variable, so you wouldn't need to create an additional variable for the intermediate result.
Weird new problem. Now when I open the app, and click the "select actions to run" button I get a null pointer error.
java.lang.NullPointerException: Cannot invoke method tokenize() on null object on line 2547 (selectActions)
Of course I have no way of knowing what object this function is being called on do I? I could always delete it and recreate it. It's just really weird because it was working earlier when I posted the screenshot. I didn't change anything, and now it's not working.