I thought about adding this a long time ago, but a subtract doesn’t make sense. Add does, you can list out n entities and it adds them. But what about subtract… everything is subtracted from the first value? Seems odd to me. Either way, it’s a new integration so it doesn’t really fall into the scope of wth.
What is the easiest way to scale a sensor output or perform other mathematical operations on a sensor output and be able to use that output within automations?
#I added the following to configuration.yaml and restarted HA.
# configuration.yaml entry for Compensation integration on Solar panel power estimator
compensation:
estimated_pv_panel_power:
source: sensor.small_solar_panel_voltage
#attribute: volume_level
unit_of_measurement: W
data_points:
- [0.00, 0.00]
- [9.15, 8.00]
#Should I see a new entity in in the entities list? Where can I find the scaled output and will it's name be "estimated_pv_panel_power"
The Compensation entity worked very well for scaling the sensor input, at least for the first 60% of the function where the relationship is linear. I see that the integration supports higher degrees. Is there a general rule of how many data_points are needed for higher degrees? If I add more points, but keep the degree at 1, will I get a piece wise or segmented linear compensation?
Is there a way that the value from another sensor could be subtracted from the compensated value to create an entity with a net result?
No, it compensates the entire set with 1 degree polynomial. What you’re describing is called ‘interpolation’. It’s something I’ve wanted to add to it, but haven’t come up with a good way of handling it without breaking changes.
Whenever I try to include the data points that are commented out, the output goes to extremely high positive and negative values in the hundreds of thousands. As soon as I try increasing the number of degrees from two to three, and including the next commented out data point, the output goes wild again. What causes this? Are my data points too similar to one another? Is the zero output in the first data point a problem?
Is there a way to test updates to the compensation, without restarting HA? For the filters that follow the compensation, I can use Filter Entities button in the YAML configuration reloading page. Is there something similar for the compensation integration?
I have tried increasing to 7 degrees and using all 8 data points, and the output goes out of control. This is the compensation curve that I am trying to achieve (the green line).