I’ve setup the following to compare actual consumption of water with predicted:
- Configured the following flows in node-red (still running manually and with debug nodes, later will automate and delete the debug nodes):
Code here:
[{"id":"0cfd43a5b58423a3","type":"inject","z":"d487ddbb6fe9ee48","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"days_to_retrieve\":7,\"var_model\":\"sensor.agua_streamlabs\",\"model_type\":\"my_custom_model\",\"sklearn_model\":\"KNeighborsRegressor\",\"num_lags\":48,\"split_date_delta\":\"48h\",\"perform_backtest\":\"False\"}","payloadType":"json","x":230,"y":180,"wires":[["20f58003f042c8f1"]]},{"id":"20f58003f042c8f1","type":"http request","z":"d487ddbb6fe9ee48","name":"Forecast Model Fit","method":"POST","ret":"bin","paytoqs":"ignore","url":"http://localhost:5000/action/forecast-model-fit","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":450,"y":180,"wires":[["68cb84c07b5a0361"]]},{"id":"68cb84c07b5a0361","type":"debug","z":"d487ddbb6fe9ee48","name":"debug 25","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":700,"y":180,"wires":[]},{"id":"d55ee4456bcf294e","type":"inject","z":"d487ddbb6fe9ee48","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"days_to_retrieve\":7,\"var_model\":\"sensor.agua_streamlabs\"}","payloadType":"json","x":230,"y":300,"wires":[["a3ba44439ed1c0da"]]},{"id":"a3ba44439ed1c0da","type":"http request","z":"d487ddbb6fe9ee48","name":"Forecast Model Tune","method":"POST","ret":"bin","paytoqs":"ignore","url":"http://localhost:5000/action/forecast-model-tune","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":460,"y":300,"wires":[["d725e885e47387d2"]]},{"id":"d725e885e47387d2","type":"debug","z":"d487ddbb6fe9ee48","name":"debug 27","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":700,"y":300,"wires":[]},{"id":"36076dcd02bce423","type":"inject","z":"d487ddbb6fe9ee48","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"model_predict_publish\":\"True\",\"model_predict_entity_id\":\"sensor.agua_streamlabswater_prediction_emhass\",\"var_model\":\"sensor.agua_streamlabs\",\"model_type\":\"my_custom_model\",\"days_to_retrieve\":7}","payloadType":"json","x":230,"y":420,"wires":[["6753f2abee4df3e2"]]},{"id":"6753f2abee4df3e2","type":"http request","z":"d487ddbb6fe9ee48","name":"Forecast Model Predict","method":"POST","ret":"bin","paytoqs":"ignore","url":"http://homeassistant:5000/action/forecast-model-predict","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":470,"y":420,"wires":[["820856ac20763445"]]},{"id":"820856ac20763445","type":"debug","z":"d487ddbb6fe9ee48","name":"debug 28","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":700,"y":420,"wires":[]},{"id":"3ac6d85e1ed0dadc","type":"comment","z":"d487ddbb6fe9ee48","name":"----- Machine Learning Forecast Água Streamlabswater ----","info":"","x":380,"y":80,"wires":[]},{"id":"1c593b38d1ec0858","type":"comment","z":"d487ddbb6fe9ee48","name":"Passo 1: Executar o Model Fit","info":"","x":280,"y":140,"wires":[]},{"id":"b9207e450e10f6c6","type":"comment","z":"d487ddbb6fe9ee48","name":"Passo 2: Executar o Model Tune (optimização)","info":"","x":330,"y":260,"wires":[]},{"id":"95f6dcd21fe773ab","type":"comment","z":"d487ddbb6fe9ee48","name":"Passo 3: Publicar resultados do Model Tune no sensor de previsão","info":"","x":400,"y":380,"wires":[]}]
-
Created a new template sensor, as the one determined by Step 3 (Passo 3) returns “Power” on state_class and “W” on unit of measure (not sure why):
-
Created a graph where will be comparing actuals vs prediction:
Code here:
type: custom:apexcharts-card
graph_span: 2d
span:
start: day
offset: '-24h'
now:
show: true
label: now
header:
show: false
title: Consumo Água (real vs previsto)
show_states: true
colorize_states: true
series:
- entity: sensor.agua_streamlabswater_forecast_model_prediction_emhass
name: Prediction
- entity: sensor.agua_streamlabs
name: Actuals