本帖最后由 pomans 于 2023-1-31 22:44 编辑
自己用的hacs安装了china southern power grid statistics获取南网电费
这个集成获取的本月电费数据属性如下格式:
state_class: total
unit_of_measurement: kWh
device_class: energy
icon: mdi:lightning-bolt
friendly_name: 本月用电量
this_month_by_day:
- date: '2023-01-01'
kwh: 4.69
- date: '2023-01-02'
kwh: 5.01
- date: '2023-01-03'
kwh: 5.39
- date: '2023-01-04'
kwh: 4.17
- date: '2023-01-05'
kwh: 2.92
想用Apexcharts卡片显示本月每天的电费使用情况
参考了帖子https://bbs.hassbian.com/forum.p ... =%E7%94%B5%E8%B4%B9
想使用这部分代码显示:
type: vertical-stack
cards:
- type: custom:apexcharts-card
header:
show: true
title: 当月用电趋势图
graph_span: 35d
span:
start: month
offset: '-30d'
series:
- entity: sensor.everyday_power2
data_generator: |
return entity.attributes.date.map((item, index) => {
return [new Date(item).getTime(), entity.attributes.power[index]];
});
extend_to: false
float_precision: 2
name: 每日电量(kWh)
实在不懂JS,怎么改都出不来数据,请求大神指点迷津
|