Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - platform: sql
- queries:
- - name: Grid total Energy
- 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') );"
- unit_of_measurement: "kWh"
- column: "state"
- - platform: sql
- queries:
- - name: Grid total Cost
- 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') );"
- column: "state"
- unit_of_measurement: "DKK"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement