找回密码
 立即注册

微信扫码登录

搜索
楼主: cjnt007

[UI界面] 【分享中~~~】国家电网数据、图表展示研究

 火... [复制链接]

7

主题

39

回帖

667

积分

高级会员

积分
667
金钱
621
HASS币
0
发表于 2025-6-22 15:26:04 | 显示全部楼层
学习学习
回复

使用道具 举报

2

主题

502

回帖

3176

积分

论坛元老

积分
3176
金钱
2672
HASS币
0
QQ
发表于 2025-6-22 15:55:22 | 显示全部楼层
感谢分享,,,
回复

使用道具 举报

0

主题

10

回帖

121

积分

注册会员

积分
121
金钱
111
HASS币
0
发表于 2025-6-23 01:52:15 | 显示全部楼层
谢谢分享,试一下看看
回复

使用道具 举报

0

主题

133

回帖

2194

积分

金牌会员

积分
2194
金钱
2061
HASS币
0
发表于 2025-6-23 08:38:39 | 显示全部楼层
感谢楼主分享!
回复

使用道具 举报

1

主题

35

回帖

227

积分

中级会员

积分
227
金钱
191
HASS币
0
发表于 2025-6-23 10:40:15 | 显示全部楼层
我也来研究下这个
回复

使用道具 举报

23

主题

537

回帖

3731

积分

论坛元老

积分
3731
金钱
3171
HASS币
18
 楼主| 发表于 2025-6-23 12:11:36 | 显示全部楼层
大佬在后续版本的更新中,添加了sensor.state_grid_xxxx_recent_30_daily_ele_list 和 sensor.state_grid_xxxx_recent_12_monthly_ele_list 两个实体,分别提供最近30天日用电量和最近12个月电量、电费数据,这样的话,就可以直接通过这两个实体获取到历史用电数据,而不用通过NR流程来整理数据了。
相应的图表代码分享如下:

微信截图_20250623121022.png

type: custom:apexcharts-card
series:
  - entity: sensor.state_grid_你的用户号_recent_30_daily_ele_list
    name: 家庭名称
    color: "#f9d505"
    opacity: 1
    stroke_width: 0
    type: column
    curve: smooth
    extend_to: end
    float_precision: 2
    fill_raw: last
    data_generator: |
      return entity.attributes.graph.map((d) => {
        return [new Date(d.day.substr(0,4)+'-'+d.day.substr(4,2)+'-'+d.day.substr(6,2)).getTime(), d.ele];
      });
    show:
      datalabels: false
      extremas: false
      name_in_header: true
      header_color_threshold: true
    color_threshold:
      - value: 0
        color: "#58FA21"
        opacity: 1
      - value: 15
        color: "#F7FF00"
        opacity: 1
      - value: 30
        color: "#FF9500"
        opacity: 1
graph_span: 30d
span:
  end: day
show:
  last_updated: false
now:
  show: true
  color: "#804aff"
  label: 现在
header:
  show: true
  show_states: true
  colorize_states: true
  title: 每日电量月视图
  standard_format: false
apex_config:
  grid:
    position: front
    borderColor: "#F0F5F2"
    strokeDashArray: 3
    row:
      colors:
        - black
        - transparent
      opacity: 0
    xaxis:
      lines:
        show: false
    yaxis:
      lines:
        show: true
  chart:
    stacked: false
    height: 210
  xaxis:
    tickPlacement: "off"
    labels:
      show: true
      style:
        colors: "#F0F5F2"
        fontSize: 12px
      format: MM/dd
    axisBorder:
      show: true
      color: "#F0F5F2"
      height: 1
    axisTicks:
      show: true
      borderType: solid
      color: "#F0F5F2"
      height: 4
    crosshairs:
      show: true
      width: 1
      position: front
      opacity: 1
      stroke:
        color: "#464A47"
        width: 1
        dashArray: 2
    tooltip:
      enabled: false
  yaxis:
    show: true
    showAlways: false
    logarithmic: false
experimental:
  color_threshold: true


微信截图_20250623121035.png

type: custom:apexcharts-card
apex_config:
  chart:
    stacked: true
  xaxis:
    tickPlacement: "on"
    labels:
      show: true
      style:
        colors: "#F0F5F2"
        fontSize: 12px
      format: yy/MM
    tooltip:
      enabled: false
graph_span: 360d
span:
  end: month
show:
  loading: true
header:
  show: true
  show_states: true
  colorize_states: true
  title: 每月电量年视图
yaxis:
  - id: ll
    decimals: 0
    max: 1100
    min: 0
  - id: rr
    opposite: true
    decimals: 0
    max: 550
    min: 0
series:
  - entity: sensor.state_grid_你的用户号_recent_12_monthly_ele_list
    data_generator: |
      return entity.attributes.graph.map((m) => {
        return [new Date(m.month.substr(0,4)+'-'+m.month.substr(4,2)+'-01').getTime(), m.ele];
      });
    name: 电量
    type: column
    color: "#fbbc05"
    yaxis_id: ll
  - entity: sensor.state_grid_你的用户号_recent_12_monthly_ele_list
    data_generator: |
      return entity.attributes.graph.map((m) => {
        return [new Date(m.month.substr(0,4)+'-'+m.month.substr(4,2)+'-01').getTime(), m.cost];
      });
    name: 电费
    type: line
    extend_to: false
    unit: 元
    color: red
    yaxis_id: rr



回复

使用道具 举报

11

主题

65

回帖

436

积分

中级会员

积分
436
金钱
360
HASS币
0
发表于 2025-6-23 15:16:07 | 显示全部楼层
厉害!厉害!厉害!
回复

使用道具 举报

11

主题

65

回帖

436

积分

中级会员

积分
436
金钱
360
HASS币
0
发表于 2025-6-23 15:26:18 | 显示全部楼层
cjnt007 发表于 2025-6-23 12:11
大佬在后续版本的更新中,添加了sensor.state_grid_xxxx_recent_30_daily_ele_list 和 sensor.state_grid_x ...

最新的插件在哪里下载?
回复

使用道具 举报

0

主题

3

回帖

39

积分

新手上路

积分
39
金钱
36
HASS币
0
发表于 2025-6-25 12:38:47 | 显示全部楼层
感谢分享
回复

使用道具 举报

0

主题

9

回帖

57

积分

注册会员

积分
57
金钱
48
HASS币
0
发表于 2025-6-27 16:56:49 | 显示全部楼层
不错,过来学习了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian ( 晋ICP备17001384号-1 )

GMT+8, 2025-8-21 02:15 , Processed in 0.064202 second(s), 12 queries , MemCached On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表