Advertisement
Rasmus_Thomsen

El pris HA

Oct 12th, 2022
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1.  
  2. - platform: sql
  3. queries:
  4. - name: Grid total Energy
  5. query: "select *, round(sum((import - day_before_import)-(export - day_before_export)),2) as state from (SELECT max(sum) as import, (SELECT max(sum) FROM statistics s join statistics_meta sm on s.metadata_id = sm.id where statistic_id = 'sensor.filtered_kamstrup_total_export' and created > date('now') ) as export, (SELECT max(sum) FROM statistics s join statistics_meta sm on s.metadata_id = sm.id where statistic_id = 'sensor.filtered_kamstrup_total_import' and created < date('now')) as day_before_import, (SELECT max(sum) FROM statistics s join statistics_meta sm on s.metadata_id = sm.id where statistic_id = 'sensor.filtered_kamstrup_total_export' and created < date('now')) as day_before_export FROM statistics s join statistics_meta sm on s.metadata_id = sm.id where statistic_id = 'sensor.filtered_kamstrup_total_import' and created > date('now') );"
  6. unit_of_measurement: "kWh"
  7. column: "state"
  8.  
  9. - platform: sql
  10. queries:
  11. - name: Grid total Cost
  12. query: "select *, round(sum((import - day_before_import)-(export - day_before_export)),2) as state from (SELECT max(sum) as import, (SELECT max(sum) FROM statistics s join statistics_meta sm on s.metadata_id = sm.id where statistic_id = 'sensor.filtered_kamstrup_total_export_compensation' and created > date('now') ) as export, (SELECT max(sum) FROM statistics s join statistics_meta sm on s.metadata_id = sm.id where statistic_id = 'sensor.filtered_kamstrup_total_import_cost' and created < date('now')) as day_before_import, (SELECT max(sum) FROM statistics s join statistics_meta sm on s.metadata_id = sm.id where statistic_id = 'sensor.filtered_kamstrup_total_export_compensation' and created < date('now')) as day_before_export FROM statistics s join statistics_meta sm on s.metadata_id = sm.id where statistic_id = 'sensor.filtered_kamstrup_total_import_cost' and created > date('now') );"
  13. column: "state"
  14. unit_of_measurement: "DKK"
  15.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement