Sunrise/Sunset data
-
I would like to be able to get the current sunrise or sunset times in human readable format from MSR so I can pass the values to Hubitat. I can set a variable on the Hubitat virtual omni sensor but I need some ideas of how to get the data. Is there a variable, expression or how do I convert
suninfo.sunrise=1629978877000. Is there a better way? Thanks -
I would like to be able to get the current sunrise or sunset times in human readable format from MSR so I can pass the values to Hubitat. I can set a variable on the Hubitat virtual omni sensor but I need some ideas of how to get the data. Is there a variable, expression or how do I convert
suninfo.sunrise=1629978877000. Is there a better way? Thanks -
@3rdstng Yes, Since I have moved my logic off of Hubitat to MSR, I wanted to have the actual source of my triggers displayed on the Hubitat dashboard as I still use that. The time might be slightly different between the two systems. Thanks
-
getEntity( "reactor_system>sun" ).attributes.suninfo.sunset
(or.sunrise
or.civil_dawn
or ...) is the attribute you're looking for.I still haven't hooked up a
strftime()
function in the expressions. Let me take care of that today and I'll post a new build at the end of the day. -
strftime()
is now part of new build 21239. docs -
strftime()
is now part of new build 21239. docsThe function strftime() works good. So now I have to say that I don't have a clue what I am doing with expressions. I created a global expression and it returns the correct value.
I need some help on how to get this to Hubitat. I can pass data using a Virtual Omni Sensor in Hubitat and manually entering data in the x_hubitat_extra_commands.setVariable. I thought I could use the perfromAction but I am confused on how the expressions are supposed to work. It looks like it just assigns to a variable so I don't know how to do a performAction.
Can someone give me some gentle advice so I can learn this?
-
The function strftime() works good. So now I have to say that I don't have a clue what I am doing with expressions. I created a global expression and it returns the correct value.
I need some help on how to get this to Hubitat. I can pass data using a Virtual Omni Sensor in Hubitat and manually entering data in the x_hubitat_extra_commands.setVariable. I thought I could use the perfromAction but I am confused on how the expressions are supposed to work. It looks like it just assigns to a variable so I don't know how to do a performAction.
Can someone give me some gentle advice so I can learn this?
@sweetgenius @sweetgenius Well, first, you're going to do either of the above actions, not both. And I would recommend against the
performAction()
expression, because it will execute every time the rule is evaluated, not just when the rule is set, which is guaranteed to be more frequent than that, and maybe annoyingly/incorrectly so.The arguments for the freeform/native Hubitat action are Hubitat dependent/device implementation dependent, and I have no idea what they are... you need to look at the definition of the Omni sensor device, and specifically that action. But since most Hubitat actions only take one value, you might try leaving argument2 blank and using this for argument1:
${{ sunsetE }}
This will do a substitution with the value of
sunsetE
. Substitutions are mentioned in the documentation. Look at thereactor.log
file to see what is sent and returned.Since global variables are only updated when used, your
sunsetE
variable is not going to update automatically every day. This rule you are setting up needs to set daily after midnight at some point. This will both updatesunsetE
and cause it to be sent to the device.Also, you can avoid the need for
ltrim()
in your expression by using%-l
format for the hour. The-
modifier removes padding. -
@sweetgenius @sweetgenius Well, first, you're going to do either of the above actions, not both. And I would recommend against the
performAction()
expression, because it will execute every time the rule is evaluated, not just when the rule is set, which is guaranteed to be more frequent than that, and maybe annoyingly/incorrectly so.The arguments for the freeform/native Hubitat action are Hubitat dependent/device implementation dependent, and I have no idea what they are... you need to look at the definition of the Omni sensor device, and specifically that action. But since most Hubitat actions only take one value, you might try leaving argument2 blank and using this for argument1:
${{ sunsetE }}
This will do a substitution with the value of
sunsetE
. Substitutions are mentioned in the documentation. Look at thereactor.log
file to see what is sent and returned.Since global variables are only updated when used, your
sunsetE
variable is not going to update automatically every day. This rule you are setting up needs to set daily after midnight at some point. This will both updatesunsetE
and cause it to be sent to the device.Also, you can avoid the need for
ltrim()
in your expression by using%-l
format for the hour. The-
modifier removes padding.@toggledbits Yes, I was showing both to try to explain what I wanted to do and also the substitution did work in the argument1 box of the Omni sensor. The finished rule would be set to run after midnight.
Update, I went away from the Omni sensor and created hub variables on the Hubitat hub and made them visible to MSR. I am setting these variables with local expressions in the rule. Not sure if this is the best or most efficient way but it does work. Any other suggestions are welcomed but thank you for the help.
Here are the expressions. -
Not recommended, as I said before, so use
performAction
in this way. The Entity Action action in the SET Reaction of your rule is the better choice. -
Not recommended, as I said before, so use
performAction
in this way. The Entity Action action in the SET Reaction of your rule is the better choice.@toggledbits Whoops, I totally misread what you posted. I have corrected per you recommendations. Thanks
-
T toggledbits locked this topic on