renhai-lab / sgcc_electricity

本应用可以帮助你将国网的电费、用电量数据接入homeassistant,并且储存到数据库。
160 stars 44 forks source link

请问该如何使用数据库的数据 #31

Closed jhchenchong closed 1 year ago

jhchenchong commented 1 year ago

sensor.last_electricity_usage因为国网数据延迟,连续好几天可能获取到的都是同一天的数据,如果使用这个数据做图表,数据不对。我该如何使用已经保存到数据库里面的最近30天的用电量呢。 2023-10-16 07:00:29 [INFO ] ---- Get electricity charge balance for 1648835216 successfully, balance is 153.41 CNY. 2023-10-16 07:00:34 [INFO ] ---- Get year power usage for 1648835216 successfully, usage is 2208 kwh 2023-10-16 07:00:34 [INFO ] ---- Get year power charge for 1648835216 successfully, yealrly charge is 1148.19 CNY 2023-10-16 07:00:39 [INFO ] ---- 2023-10-14的用电量4.65KWh已经成功存入数据库 2023-10-16 07:00:39 [INFO ] ---- 2023-10-12的用电量4.39KWh已经成功存入数据库 2023-10-16 07:00:40 [INFO ] ---- 2023-10-11的用电量3.76KWh已经成功存入数据库 2023-10-16 07:00:44 [INFO ] ---- Get daily power consumption for 1648835216 successfully, , 2023-10-14 usage is 4.65 kwh. 2023-10-16 07:00:44 [INFO ] ---- Webdriver quit after fetching data successfully. 2023-10-16 07:00:44 [INFO ] ---- 浏览器已退出 2023-10-16 07:00:45 [INFO ] ---- Homeassistant sensor sensor.electricity_charge_balance state updated: 153.41CNY 2023-10-16 07:00:45 [INFO ] ---- Homeassistant sensor sensor.last_electricity_usage state updated: 4.65KWH 2023-10-16 07:00:45 [INFO ] ---- Homeassistant sensor sensor.yearly_electricity_usage state updated: 2208KWH 2023-10-16 07:00:45 [INFO ] ---- Homeassistant sensor sensor.yearly_electricity_charge state updated: 1148.19CNY 2023-10-16 07:00:45 [INFO ] ---- state-refresh task run successfully!

renhai-lab commented 1 year ago

推荐使用nodered:在nodered中安装node-red-contrib-mongodb4节点,就可以查询数据然后配合homeassistant使用了。

jhchenchong commented 1 year ago

好的,谢谢!