I have a custom SolarEdge device driver (with tile formatting in the code) for my solar panel energy convertor. I found the custom Hubitat device driver someone else created some time ago and have been able to add solar convertor tiles in my Hubitat dashboard. These tiles have an over view of solar production, current power, consumption, etc.
I was able to import the device into SharpTools under the Other Sensors category. The various attributes are exposed as I initially added the thing in a Hero format; however, the attributes are the raw values (i.e., 60000 W) and I would like to format the values to my desired units (i.e., kW). I just need to be able to divide the attribute values by 1,000 and then I can add the desired label.
Am I able to do this in SharpTools and what would be the best way to go about this?
It sounds like you would need some sort of math functionality to accomplish this. There’s a feature request for Math with Variables for the SharpTools Rule Engine which will likely get some love soon.
In the meantime, you could probably accomplish it either:
Using a Hubitat Rule + Hubitat Variables (+ Variable Connector)
Using a Custom Tile + Hubitat Maker API*
The first approach is native to Hubitat, but requires creating rules and a variable (+connector) to sync over to SharpTools. The second approach requires some HTML+JS skills.
I would recommend casting a vote on the Math with Variables feature request linked above!
I used the Hubitat Rule + Hubitat Variable (+ Variable Connector) method you suggested to transform the attribute values (i.e., convert to kWh and MWh from W) and then expose them to SharpTools via the variable connector.
Next I created a SuperTile in SharpTools, using the attribute values (i.e., connected Hubitat variables). The result was mostly what I was after:
But, as you can see, sometimes the values in the SuperTile aren’t displayed as converted to kWh or MWh as I’d like. The Hubitat Rule I created watches for a change in the underlying SolarEdge device “CurrentProduction” attribute value (which gets updated every 15 minutes as configured in the Hubitat device config) and then kicks off a store and transform process. I store the device attribute values in respective Hubitat variables, then perform Hubitat variable math (i.e., divide each stored value to get the desired conversion and then re-store to the variable (e.g., CurrentProduction = CurrentProduction / 1000).
The Hubitat rule seems to run correctly and I have verified the Hubitat variables are all converted stored as such in their respective Hubitat variables, but for some reason the when the values update in SharpTools SuperTile often one or two values don’t show the actual Hubitat variable value.
Here are the Hubitat variable values to show they are stored correctly:
Any thoughts why this might be? I tried adding a couple seconds delay between each Hubitat variable math (i.e., the division function) in the Rule but that didn’t fix the issue.
When the issue occurs, can you double check the variable connector device in Hubitat?
The connector device is what’s connected to SharpTools, so that’s what it’s displaying data from.
Alternatively, you may have seen that we put together a labs feature to perform Math if you wanted to do the conversion with that and store it into a SharpTools variable. (We also plan to revisit this with a native math feature as originally alluded to)
I just checked the Hubitat variables and the variable connector device in Hubitat and checked the values of the child devices (i.e., the variables) and they are all correct/as expected; however, currently one of values is not showing converted (divided by 1,000) as expected on the SuperTile in my SharpTools dashboard.
Also, it is not the same variable that has an issue with showing converted correctly in my SuperTile. Every time the Hubitat Rule runs, which is about every 15 minutes, it’s a crap shoot which variable(s) doesn’t display correctly converted in the SuperTile.
If you want to share more details about the Hubitat rule and screenshots showing the event history of an impacted connector device along with the device in SharpTools, perhaps that would help.
Otherwise the labs feature mentioned above would be an alternative way to handle it.
The variable connector device (the parent container) doesn’t have any entries in event history. Here is the parent device and the child devices (variables):
All 4 variables in HE and ST are configured the same, meaning the actions performed in the HE Rule, the HE variable math, the variable connectors and the handling of the variables in ST are handled/configured the same.
Can you do the calculation in one step – in other words, without staging the device value to the variable before running the calculation?
I’m not sure if Rule Machine supports it, but something like:
Set LastDayProduction to (Solar Monitor last_day / 1000.0)
I suspect that it’s a timing issue with both events happening so quickly. With certain values like switches, contact sensors, motion sensors, etc we only allow the newest timestamped value. This special forced ordering is not the applied to ordinal values.