As someone with a background in SQL development and dataanalytics i could not resist the temptation to do some queries now i have more than a year of available data.
Also i wanted to see if i could use "Common Expression Tables" in SqLite3.
Using a P1 interface my energy consumption is registed. Via a OTGW the behavious of the CentalHeating boiler is monitored.
in our home, we use gas for:
- heating (this is the bulk of my gas usage)
- cooking
- hotwater
i was curious to learn how much gas we use for Non-Heating purpose. I tried this by averaging the gas consumption over the 'Non-Heatingdays' (heater was not used)
Code: Select all
-- Sensor "Control Setpoint" (idx=17) the 'Temp_Max' value indicates that the heater was
-- used during the Day. When heater not used it is 10, if the heater was used, it's >10.
WITH
CTE_HeatingDays AS (
SELECT Date FROM Temperature_Calendar WHERE (DeviceRowID=17 AND Temp_Max>10)
), CTE_NonHeatingDays AS (
SELECT Date FROM Temperature_Calendar WHERE (DeviceRowID=17 AND NOT(Temp_Max>10))
), CTE_GasUsed AS (
-- Gas meter is idx=46, Usage is in m3/1000
SELECT Date, Value FROM Meter_Calendar WHERE (DeviceRowID=46)
), CTE_GasUsedNonHeatingDays AS (
-- Join the non-heatingdays with the gas usage
SELECT A.Date, B.Value FROM CTE_NonHeatingDays AS A
INNER JOIN CTE_GasUsed AS B ON A.Date=B.Date
), CTE_GasUsedHeatingDays AS (
-- Join the heatingdays with the gas usage
SELECT A.Date, B.Value FROM CTE_HeatingDays AS A
INNER JOIN CTE_GasUsed AS B ON A.Date=B.Date
)
--SELECT COUNT(*) AS NonHeatingDays, SUM(Value)/COUNT(*) AS "GasUsed/1000" FROM CTE_GasUsedNonHeatingDays;
SELECT COUNT(*) AS HeatingDays, SUM(Value)/COUNT(*) AS "GasUsed/1000" FROM CTE_GasUsedHeatingDays;
Code: Select all
sqlite> .read cte_example.sql
NonHeatingDays|GasUsed/1000
343|299
sqlite>
My conclusion is that we use 109m3/year for non heating application (0,299 *365)
If i change the SQL (uncomment/comment the other SELECT) i get:
Code: Select all
sqlite> .read cte_example.sql
HeatingDays|GasUsed/1000
240|2525
sqlite>
realise my data set is 583 days (343+240) long and this is not something that predicts my total year consumption. But that was not the purpose of this experiment.