『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
楼主: befantasy

[技术探讨] 路由器流量统计

[复制链接]

9

主题

180

帖子

1257

积分

金牌会员

Rank: 6Rank: 6

积分
1257
金钱
1077
HASS币
0
 楼主| 发表于 2022-3-8 12:24:00 | 显示全部楼层
15283928038 发表于 2022-3-5 10:15
请教一下实时速度的代码,这个单位怎么换算成M/s

实时速率看你用哪个custom card实现了。基本都有数值换算的选项。
我用的mini-graph-card
有个value_factor的选项,小数点左移三位的话就是-3,右移三位是3
value_factor: -3
回复

使用道具 举报

4

主题

138

帖子

1243

积分

金牌会员

Rank: 6Rank: 6

积分
1243
金钱
1105
HASS币
0
发表于 2022-3-14 10:04:57 | 显示全部楼层
非常感谢已经添加上了。
回复

使用道具 举报

7

主题

95

帖子

710

积分

高级会员

Rank: 4

积分
710
金钱
615
HASS币
0
发表于 2022-3-15 04:09:10 | 显示全部楼层
befantasy 发表于 2022-1-28 23:53
感谢各位帮助,好像用Utility Meter加apexcharts-card已经可以了。

能分享下 mini-graph-card 的配置吗? 实时速率 和  温湿度的 都很好看,我配了半天,效果不是很满意。
回复

使用道具 举报

8

主题

154

帖子

1162

积分

论坛技术达人

积分
1162
金钱
998
HASS币
20
发表于 2022-3-15 09:13:37 | 显示全部楼层
befantasy 发表于 2022-1-28 23:53
感谢各位帮助,好像用Utility Meter加apexcharts-card已经可以了。

能提供下您这张图的源码配置吗?感觉非常好看~谢谢。
回复

使用道具 举报

9

主题

180

帖子

1257

积分

金牌会员

Rank: 6Rank: 6

积分
1257
金钱
1077
HASS币
0
 楼主| 发表于 2022-3-16 21:38:51 | 显示全部楼层
qqkj 发表于 2022-3-15 04:09
能分享下 mini-graph-card 的配置吗? 实时速率 和  温湿度的 都很好看,我配了半天,效果不是很满意。 ...

type: vertical-stack
cards:
  - show_current: true
    show_forecast: true
    type: weather-forecast
    entity: weather.home
    secondary_info_attribute: wind_speed
  - type: thermostat
    entity: climate.v3_cloud_674156
  - type: horizontal-stack
    cards:
      - type: custom:mini-graph-card
        entities:
          - sensor.v1_cloud_0a00df_temperature
        name: 温度
        points_per_hour: 2
        hour24: true
        line_color: var(--accent-color)
        decimals: 0
        height: 200
        line_width: 6
        font_size: 100
        min_bound_range: 5
        align_state: center
        animate: false
        smoothing: true
        show:
          extrema: true
          labels: true
      - type: custom:mini-graph-card
        entities:
          - sensor.v1_cloud_0a00df_humidity
        name: 湿度
        points_per_hour: 2
        hour24: true
        line_color: '#3397da'
        decimals: 0
        height: 200
        line_width: 6
        font_size: 100
        min_bound_range: 10
        align_state: center
        animate: false
        smoothing: true
        show:
          extrema: true
          labels: true



---------------------------------------------------------


type: custom:mini-graph-card
name: 实时速率
entities:
  - entity: sensor.asuswrt_kib_s_sent
    state_adaptive_color: true
    show_state: true
    show_fill: true
    name: 上传
    color: '#3397da'
  - entity: sensor.asuswrt_kib_s_received
    state_adaptive_color: true
    show_state: true
    show_fill: true
    name: 下载
    color: '#7b4a8d'
points_per_hour: 60
hours_to_show: 1
font_size: 90
height: 120
decimals: 1
line_width: 3
animate: false
smoothing: true
align_state: center
value_factor: -3
unit: MB/s
show:
  legend: false
  labels: true
  icon: false
  points: false
  fill: true



回复

使用道具 举报

9

主题

180

帖子

1257

积分

金牌会员

Rank: 6Rank: 6

积分
1257
金钱
1077
HASS币
0
 楼主| 发表于 2022-3-16 21:39:52 | 显示全部楼层
wen_jxpx 发表于 2022-3-15 09:13
能提供下您这张图的源码配置吗?感觉非常好看~谢谢。

哪个card?
回复

使用道具 举报

7

主题

95

帖子

710

积分

高级会员

Rank: 4

积分
710
金钱
615
HASS币
0
发表于 2022-3-17 04:08:08 | 显示全部楼层
befantasy 发表于 2022-3-16 21:38
type: vertical-stack
cards:
  - show_current: true

好的谢谢!!
我试了你的这个流量统计功能,可以统计,但是数字不对, 我从路由器获取的实时流量数据是30秒采样一次。。所以统计的流量会非常少。没办法用,不知你是怎么解决的。
回复

使用道具 举报

8

主题

154

帖子

1162

积分

论坛技术达人

积分
1162
金钱
998
HASS币
20
发表于 2022-3-17 08:39:39 | 显示全部楼层

整个页面的配置文件。 所有的card  哈哈。
回复

使用道具 举报

9

主题

180

帖子

1257

积分

金牌会员

Rank: 6Rank: 6

积分
1257
金钱
1077
HASS币
0
 楼主| 发表于 2022-3-17 09:28:05 | 显示全部楼层
本帖最后由 befantasy 于 2022-3-17 09:32 编辑
qqkj 发表于 2022-3-17 04:08
好的谢谢!!
我试了你的这个流量统计功能,可以统计,但是数字不对, 我从路由器获取的实时流量数据是30 ...

你说的是实时流量还是分时流量统计? 我上面发的那个是实时流量。分时流量统计是这个:

type: custom:apexcharts-card
update_interval: 2m
stacked: false
graph_span: 13h
span:
  end: hour
hours_12: false
header:
  show: true
  title: 网络流量
  show_states: false
  colorize_states: true
series:
  - entity: sensor.hourly_upload
    transform: return x / 1073741824;
    unit: G
    name: 上传
    type: column
    color: '#3397da'
    opacity: 0.6
    group_by:
      func: max
      duration: 1h
    show:
      legend_value: false
  - entity: sensor.hourly_download
    transform: return x / 1073741824;
    unit: G
    name: 下载
    type: column
    color: '#7b4a8d'
    opacity: 0.6
    group_by:
      func: max
      duration: 1h
    show:
      legend_value: false
apex_config:
  chart:
    height: 200px


回复

使用道具 举报

9

主题

180

帖子

1257

积分

金牌会员

Rank: 6Rank: 6

积分
1257
金钱
1077
HASS币
0
 楼主| 发表于 2022-3-17 09:29:46 | 显示全部楼层
wen_jxpx 发表于 2022-3-17 08:39
整个页面的配置文件。 所有的card  哈哈。

title: Home
views:
  - path: default_view
    title: Home
    badges:
      - entity: binary_sensor.updater
      - entity: person.zhang_lin
      - entity: person.tian
      - entity: person.zhang
      - entity: sensor.aq2_event_4c9534_motion_illumination
      - entity: sun.sun
      - entity: sensor.u_s_air_quality_index
    cards:
      - type: vertical-stack
        cards:
          - type: glance
            entities:
              - entity: sensor.v8_event_119461_door_door_status
                name: 门状态
              - entity: sensor.v8_event_119461_lock_lock_action
                name: 锁状态
              - entity: sensor.v8_event_119461_lock_lock_method
                name: 开锁方式
              - entity: sensor.unlock_id
                name: 操作者
            show_name: true
            state_color: false
            show_icon: true
          - type: entities
            entities:
              - entity: sensor.v8_event_119461_door_door_time
                name: 门状态时间
              - entity: sensor.v8_event_119461_lock_lock_time
                name: 锁状态时间
      - type: vertical-stack
        cards:
          - type: media-control
            entity: media_player.appletv
          - type: media-control
            entity: media_player.ke_ting_yin_xiang
          - type: custom:button-card
            name: 客厅
            styles:
              card:
                - height: 30px
                - padding: 10px 10px
          - type: horizontal-stack
            cards:
              - type: custom:button-card
                entity: switch.v1_cloud_3a6c2c
                name: 入户灯
                color_type: icon
                color: rgb(255, 214, 10)
                icon: mdi:light-recessed
                styles:
                  card:
                    - height: 65px
                    - font-size: 15px
              - type: custom:button-card
                entity: switch.v1_cloud_a24dcb
                name: 吊灯
                color_type: icon
                color: rgb(255, 214, 10)
                icon: mdi:globe-light
                styles:
                  card:
                    - height: 65px
                    - font-size: 15px
              - type: custom:button-card
                entity: switch.v1_cloud_a24dcb_switch_2
                name: 吸顶灯
                color_type: icon
                color: rgb(255, 214, 10)
                icon: mdi:wall-sconce-flat-outline
                styles:
                  card:
                    - height: 65px
                    - font-size: 15px
          - type: horizontal-stack
            cards:
              - type: custom:button-card
                entity: switch.tv
                name: 电视
                color_type: icon
                color: rgb(255, 214, 10)
                icon: mdi:television-box
                styles:
                  card:
                    - height: 65px
                    - font-size: 15px
              - type: custom:button-card
                entity: media_player.ke_ting_yin_xiang
                name: 音响
                tap_action:
                  action: call-service
                  service: media_player.media_play_pause
                  service_data:
                    entity_id: media_player.ke_ting_yin_xiang
                state:
                  - value: paused
                    color: var(--paper-item-icon-color)
                    color_type: icon
                    icon: mdi:music
                  - value: playing
                    color: rgb(255, 214, 10)
                    color_type: icon
                    icon: mdi:music
                styles:
                  card:
                    - height: 65px
                    - font-size: 15px
              - type: custom:button-card
                entity: fan.airx
                name: 净化器
                color_type: icon
                color: rgb(255, 214, 10)
                icon: mdi:air-filter
                show_state: false
                styles:
                  card:
                    - height: 65px
                    - font-size: 15px
                  grid:
                    - position: relative
                  custom_fields:
                    notification:
                      - background-color: |
                          [[[
                            if (states['sensor.airx_pm25'].state < 10)
                              return "green";
                            return "red";
                          ]]]
                      - border-radius: 50%
                      - position: absolute
                      - left: 60%
                      - top: '-5%'
                      - height: 18px
                      - width: 18px
                      - font-size: 14px
                      - line-height: 20px
                custom_fields:
                  notification: |
                    [[[ return states['sensor.airx_pm25'].state ]]]
          - type: custom:button-card
            name: 书房
            styles:
              card:
                - height: 30px
                - padding: 10px 10px
          - type: horizontal-stack
            cards:
              - type: custom:button-card
                entity: light.lamp22_cloud_515305
                name: 台灯
                color_type: icon
                color: rgb(255, 214, 10)
                icon: mdi:wall-sconce-round-outline
                styles:
                  card:
                    - height: 65px
                    - font-size: 15px
              - type: custom:button-card
                entity: switch.v1_cloud_6d4553
                name: 吸顶灯
                color_type: icon
                color: rgb(255, 214, 10)
                icon: mdi:wall-sconce-flat-outline
                styles:
                  card:
                    - height: 65px
                    - font-size: 15px
              - type: custom:button-card
                entity: switch.desktop
                name: 桌面电脑
                color_type: icon
                color: rgb(255, 214, 10)
                icon: mdi:desktop-classic
                styles:
                  card:
                    - height: 65px
                    - font-size: 15px
          - type: custom:button-card
            name: 卧室
            styles:
              card:
                - height: 30px
                - padding: 10px 10px
          - type: horizontal-stack
            cards:
              - type: custom:button-card
                entity: switch.v1_cloud_3a7a8c
                name: 主卧吸顶灯
                color_type: icon
                color: rgb(255, 214, 10)
                icon: mdi:wall-sconce-flat-outline
                styles:
                  card:
                    - height: 65px
                    - font-size: 15px
              - type: custom:button-card
                entity: switch.v1_cloud_40bc6c
                name: 次卧吸顶灯
                color_type: icon
                color: rgb(255, 214, 10)
                icon: mdi:wall-sconce-flat-outline
                styles:
                  card:
                    - height: 65px
                    - font-size: 15px
              - type: custom:button-card
                entity: fan.airx2
                name: 净化器
                color_type: icon
                color: rgb(255, 214, 10)
                icon: mdi:air-filter
                show_state: false
                styles:
                  card:
                    - height: 65px
                    - font-size: 15px
                  grid:
                    - position: relative
                  custom_fields:
                    notification:
                      - background-color: |
                          [[[
                            if (states['sensor.airx2_pm25'].state < 10)
                              return "green";
                            return "red";
                          ]]]
                      - border-radius: 50%
                      - position: absolute
                      - left: 62%
                      - top: '-5%'
                      - height: 18px
                      - width: 18px
                      - font-size: 14px
                      - line-height: 20px
                custom_fields:
                  notification: |
                    [[[ return states['sensor.airx2_pm25'].state ]]]
          - type: custom:button-card
            name: 厨卫
            styles:
              card:
                - height: 30px
                - padding: 10px 10px
          - type: horizontal-stack
            cards:
              - type: custom:button-card
                entity: switch.v1_cloud_3a6d55
                name: 厨房
                color_type: icon
                color: rgb(255, 214, 10)
                icon: mdi:wall-sconce-flat-outline
                styles:
                  card:
                    - height: 65px
                    - font-size: 15px
              - type: custom:button-card
                entity: switch.v1_cloud_40970b
                name: 洗手台
                color_type: icon
                color: rgb(255, 214, 10)
                icon: mdi:light-recessed
                styles:
                  card:
                    - height: 65px
                    - font-size: 15px
              - type: custom:button-card
                entity: switch.v1_cloud_a2d2b5_switch_2
                name: 卫生间
                color_type: icon
                color: rgb(255, 214, 10)
                icon: mdi:wall-sconce-flat-outline
                styles:
                  card:
                    - height: 65px
                    - font-size: 15px
              - type: custom:button-card
                entity: switch.v1_cloud_a2d2b5
                name: 换气扇
                color_type: icon
                color: rgb(255, 214, 10)
                icon: mdi:fan
                styles:
                  card:
                    - height: 65px
                    - font-size: 15px
      - type: vertical-stack
        cards:
          - type: weather-forecast
            entity: weather.home
            secondary_info_attribute: wind_speed
          - type: thermostat
            entity: climate.v3_cloud_674156
          - type: horizontal-stack
            cards:
              - type: custom:mini-graph-card
                entities:
                  - sensor.v1_cloud_0a00df_temperature
                name: 温度
                points_per_hour: 2
                hour24: true
                line_color: var(--accent-color)
                decimals: 0
                height: 200
                line_width: 6
                font_size: 100
                min_bound_range: 5
                align_state: center
                animate: false
                smoothing: true
                show:
                  extrema: true
                  labels: true
              - type: custom:mini-graph-card
                entities:
                  - sensor.v1_cloud_0a00df_humidity
                name: 湿度
                points_per_hour: 2
                hour24: true
                line_color: '#3397da'
                decimals: 0
                height: 200
                line_width: 6
                font_size: 100
                min_bound_range: 10
                align_state: center
                animate: false
                smoothing: true
                show:
                  extrema: true
                  labels: true
      - type: custom:xiaomi-vacuum-map-card
        title: 扫地机器人
        language: zh
        entity: vacuum.s5_cloud_473051
        vacuum_platform: default
        map_source:
          camera: camera.xiaomi_cloud_map_extractor
        calibration_source:
          camera: true
        map_locked: true
      - type: vertical-stack
        cards:
          - type: custom:apexcharts-card
            update_interval: 2m
            stacked: false
            graph_span: 13h
            span:
              end: hour
            hours_12: false
            header:
              show: true
              title: 网络流量
              show_states: false
              colorize_states: true
            series:
              - entity: sensor.hourly_upload
                transform: return x / 1073741824;
                unit: G
                name: 上传
                type: column
                color: '#3397da'
                opacity: 0.6
                group_by:
                  func: max
                  duration: 1h
                show:
                  legend_value: false
              - entity: sensor.hourly_download
                transform: return x / 1073741824;
                unit: G
                name: 下载
                type: column
                color: '#7b4a8d'
                opacity: 0.6
                group_by:
                  func: max
                  duration: 1h
                show:
                  legend_value: false
            apex_config:
              chart:
                height: 200px
          - type: custom:mini-graph-card
            name: 实时速率
            entities:
              - entity: sensor.asuswrt_kib_s_sent
                state_adaptive_color: true
                show_state: true
                show_fill: true
                name: 上传
                color: '#3397da'
              - entity: sensor.asuswrt_kib_s_received
                state_adaptive_color: true
                show_state: true
                show_fill: true
                name: 下载
                color: '#7b4a8d'
            points_per_hour: 60
            hours_to_show: 1
            font_size: 90
            height: 120
            decimals: 1
            line_width: 3
            animate: false
            smoothing: true
            align_state: center
            value_factor: -3
            unit: MB/s
            show:
              legend: false
              labels: true
              icon: false
              points: false
              fill: true
  - title: temp
    path: temp
    badges: []
    cards:
      - type: vertical-stack
        cards:
          - type: entities
            entities:
              - entity: switch.v1_cloud_3a6c2c
              - entity: switch.v1_cloud_a24dcb
              - entity: switch.v1_cloud_a24dcb_switch_2
              - entity: switch.tv
              - entity: switch.aroma
            title: 客厅
            state_color: true
            show_header_toggle: false
          - type: entities
            entities:
              - entity: switch.v1_cloud_6d4553
              - entity: light.lamp22_cloud_515305
              - entity: switch.desktop
            title: 书房
            state_color: true
            show_header_toggle: false
          - type: entities
            entities:
              - entity: switch.v1_cloud_3a7a8c
              - entity: switch.v1_cloud_40bc6c
            title: 卧室
            state_color: true
            show_header_toggle: false
          - type: entities
            entities:
              - entity: switch.v1_cloud_3a6d55
              - entity: switch.v1_cloud_40970b
              - entity: switch.v1_cloud_a2d2b5_switch_2
              - entity: switch.v1_cloud_a2d2b5
            title: 厨卫
            state_color: true
            show_header_toggle: false
      - type: entities
        entities:
          - entity: sensor.v8_event_119461_door_door_status
            name: 门状态
          - entity: sensor.v8_event_119461_lock_lock_action
            name: 锁状态
          - entity: sensor.v8_event_119461_lock_lock_method
            name: 开锁方式
          - entity: sensor.unlock_id
            name: 操作者
          - entity: sensor.v8_event_119461_door_door_time
            name: 门状态时间
          - entity: sensor.v8_event_119461_lock_lock_time
            name: 锁状态时间
        title: 门禁
        show_header_toggle: false
        state_color: false
      - entities:
          - entity: fan.airx
          - entity: sensor.airx_pm25
          - entity: sensor.airx_outside_pm25
          - entity: fan.airx2
          - entity: sensor.airx2_pm25
          - entity: sensor.airx2_outside_pm25
        show_header_toggle: true
        title: 空气净化器
        type: entities
        state_color: true
      - type: vertical-stack
        cards:
          - type: custom:apexcharts-card
            graph_span: 1h
            hours_12: false
            header:
              show: true
              title: 网络
              show_states: false
              standard_format: false
              colorize_states: true
            series:
              - entity: sensor.asuswrt_kib_s_sent
                type: area
                fill_raw: last
                opacity: 0.2
                name: 上传速率
                unit: MB/s
                stroke_width: 2.5
                transform: return x / 1024;
                group_by:
                  func: avg
                  duration: 1m
              - entity: sensor.asuswrt_kib_s_received
                type: area
                fill_raw: last
                opacity: 0.2
                name: 下载速率
                unit: MB/s
                stroke_width: 2.5
                transform: return x / 1024;
                group_by:
                  func: avg
                  duration: 1m
      - type: custom:apexcharts-card
        graph_span: 24h
        hours_12: false
        header:
          show: true
          title: 温湿度
          show_states: true
          standard_format: false
          colorize_states: true
        yaxis:
          - id: temp
            decimals: 0
            min: 18
            max: 30
            apex_config:
              tickAmount: 6
          - id: hum
            opposite: true
            decimals: 0
            min: 20
            max: 80
            apex_config:
              tickAmount: 6
        series:
          - entity: sensor.v1_cloud_0a00df_temperature
            yaxis_id: temp
            type: area
            float_precision: 0
            opacity: 0.2
            name: 温度
            stroke_width: 2.5
            group_by:
              func: avg
              duration: 30m
            show:
              extremas: true
          - entity: sensor.v1_cloud_0a00df_humidity
            yaxis_id: hum
            type: area
            float_precision: 0
            opacity: 0.2
            name: 湿度
            stroke_width: 2.5
            group_by:
              func: avg
              duration: 30m
            show:
              extremas: true
      - type: custom:simple-thermostat
        entity: climate.v3_cloud_674156
        layout:
          mode:
            headings: false
            names: true
          step: row
        decimals: '0'
        header:
          name: 空调
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-5-14 21:31 , Processed in 0.119195 second(s), 30 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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