knudsvik / EnergyScore

Custom Integration for Home Assistant to score how energy is utilized based on price point
MIT License
36 stars 4 forks source link

Low outlier values #88

Closed miguelpucela closed 1 year ago

miguelpucela commented 1 year ago

I observe sudden low values which recover after a short period.

I copy a fragment of log in which the energy score value goes down from 1.0 to 0.5 and back to 1.0 in three consecutive values. The quality of the score is over 90%. I think this is a bug, because it has no sense this strange behaviour.

Versions: EnegyScore: v1.1.3 Home Assistant 2023.1.7 Supervisor 2023.01.1 Operating System 9.5 Frontend 20230110.0 - latest

Log:

2023-01-30 11:44:03.612 DEBUG (MainThread) [custom_components.energyscore] Eficiencia termo piso - Quality: 0.92 2023-01-30 11:44:03.612 DEBUG (MainThread) [custom_components.energyscore] Eficiencia termo piso - Norm prices: [1. 1. 0. 0. 0. 1. 1. 1. 1. 0. 0. 0. 0. 1. 0. 0. 0. 0. 0. 0. 0. 1.] 2023-01-30 11:44:03.614 DEBUG (MainThread) [custom_components.energyscore] Eficiencia termo piso - Norm energy: [0.31 0. 0. 0. 0. 0. 0. 0.18 0. 0. 0. 0. 0. 0.52 2023-01-30 11:44:03.615 DEBUG (MainThread) [custom_components.energyscore] Eficiencia termo piso - Score: 1.0 2023-01-30 11:54:03.666 DEBUG (MainThread) [custom_components.energyscore] Eficiencia termo piso - Calc. energy usage: [1.16, 0.0, 0.0, 0.4, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.69, 0.0, 0.0, 0.0] 2023-01-30 11:54:03.666 DEBUG (MainThread) [custom_components.energyscore] Eficiencia termo piso - Quality: 0.92 2023-01-30 11:54:03.666 DEBUG (MainThread) [custom_components.energyscore] Eficiencia termo piso - Norm prices: [1. 1. 0. 0. 0. 1. 1. 1. 1. 0. 0. 0. 0. 1. 0. 0. 0. 0. 0. 0. 0. 1.] 2023-01-30 11:54:03.666 DEBUG (MainThread) [custom_components.energyscore] Eficiencia termo piso - Norm energy: [0.31 0. 0. 0. 0. 0. 0. 0.18 0. 0. 0. 0. 0. 0.52 2023-01-30 11:54:03.666 DEBUG (MainThread) [custom_components.energyscore] Eficiencia termo piso - Score: 1.0 2023-01-30 12:04:03.646 DEBUG (MainThread) [custom_components.energyscore] Eficiencia termo piso - Calc. energy usage: [1.16, 0.0, 0.0, 0.4, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.69, 0.0, 0.0, 0.0, 0.09] 2023-01-30 12:04:03.646 DEBUG (MainThread) [custom_components.energyscore] Eficiencia termo piso - Quality: 0.96 2023-01-30 12:04:03.646 DEBUG (MainThread) [custom_components.energyscore] Eficiencia termo piso - Norm prices: [1. 1. 0. 0. 0. 1. 1. 1. 1. 1. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 1.] 2023-01-30 12:04:03.646 DEBUG (MainThread) [custom_components.energyscore] Eficiencia termo piso - Norm energy: [0.29 0. 0. 0. 0. 0.04 0. 0. 0.17 0. 0. 0. 0. 0. 2023-01-30 12:04:03.646 DEBUG (MainThread) [custom_components.energyscore] Eficiencia termo piso - Score: 0.5042735042735035 2023-01-30 12:14:03.636 DEBUG (MainThread) [custom_components.energyscore] Eficiencia termo piso - Calc. energy usage: [0.0, 0.0, 0.4, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.69, 0.0, 0.0, 0.0, 0.32] 2023-01-30 12:14:03.636 DEBUG (MainThread) [custom_components.energyscore] Eficiencia termo piso - Quality: 0.92 2023-01-30 12:14:03.636 DEBUG (MainThread) [custom_components.energyscore] Eficiencia termo piso - Norm prices: [1. 1. 0. 0. 0. 1. 1. 1. 1. 1. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 1.] 2023-01-30 12:14:03.636 DEBUG (MainThread) [custom_components.energyscore] Eficiencia termo piso - Norm energy: [0.49 0. 0. 0. 0. 0.23 0. 0. 0.28 0. 0. 0. 0. 0. 2023-01-30 12:14:03.636 DEBUG (MainThread) [custom_components.energyscore] Eficiencia termo piso - Score: 1.0 2023-01-30 12:24:03.633 DEBUG (MainThread) [custom_components.energyscore] Eficiencia termo piso - Calc. energy usage: [0.0, 0.0, 0.4, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.69, 0.0, 0.0, 0.0, 0.55] 2023-01-30 12:24:03.633 DEBUG (MainThread) [custom_components.energyscore] Eficiencia termo piso - Quality: 0.92 2023-01-30 12:24:03.633 DEBUG (MainThread) [custom_components.energyscore] Eficiencia termo piso - Norm prices: [1. 1. 0. 0. 0. 1. 1. 1. 1. 1. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 1.] 2023-01-30 12:24:03.633 DEBUG (MainThread) [custom_components.energyscore] Eficiencia termo piso - Norm energy: [0.42 0. 0. 0. 0. 0.34 0. 0. 0.24 0. 0. 0. 0. 0. 2023-01-30 12:24:03.633 DEBUG (MainThread) [custom_components.energyscore] Eficiencia termo piso - Score: 1.0 2023-01-30 12:34:03.633 DEBUG (MainThread) [custom_components.energyscore] Eficiencia termo piso - Calc. energy usage: [0.0, 0.0, 0.4, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.69, 0.0, 0.0, 0.0, 0.79]

knudsvik commented 1 year ago

@miguelpucela Thanks for reporting!

I actually think the score is correct in regards to that it is calculating like expected based on the input. In this case the score is very sensitive because your price sensor only has two different values throughout this period. So the energy usage is either at the most expensive hour or the cheapest hour, there is nothing in between. Is there something off with your price sensor maybe?

miguelpucela commented 1 year ago

I expected a softer trend, but for sure is what you say. I only have two prices in my tariff, cheap and expensive.

Thank you!

knudsvik commented 1 year ago

I understand, I think you will get the best value from looking at the average value over 24 hours (which will be much softer) given the binary price setting!

miguelpucela commented 1 year ago

I was thinking of applying an outlier filter, but I can also try average or moving average as you suggest.