这个项目能做什么

Mini Graph Card 是 Home Assistant 的自定义 Lovelace 卡片,用于显示 sensor 和 binary_sensor 实体的当前状态,并附带其历史数据的折线图或柱状图。它可以通过 HACS 安装,也可以手动将 bundle 复制到 config/www,或通过 CLI 下载,然后在 Lovelace 中作为 JavaScript 模块资源引用。 该卡片通过 YAML 配置。必填选项是 type(custom:mini-graph-card)和 entities,即 sensor 实体列表。每个实体可以是普通实体 id,也可以是带有选项的对象,例如 attribute、name、color、unit、aggregate_func、show_state、show_legend_state、show_indicator、show_graph、show_line、show_fill、show_points、show_legend、state_adaptive_color、y_axis、fixed_value 和 smoothing。 卡片级选项包括 icon、icon_image、name、unit、tap_action、group、hours_to_show、points_per_hour、aggregate_func、group_by、update_interval、cache、show、animate、height、bar_spacing、line_width、line_color、color_thresholds、color_thresholds_transition、decimals、hour24、font_size、font_size_header、align_header、align_icon、align_state、lower_bound、upper_bound、min_bound_range、secondary bounds、smoothing、state_map、value_factor 和 logarithmic。 show 列表控制 UI 元素:name、icon、state、graph(line、bar 或 false)、fill、points、legend、average、extrema、labels、labels_secondary、name_adaptive_color、icon_adaptive_color 和 indicator。聚合函数包括 avg、median、min、max、first、last、sum、delta 和 diff。数据可以按 interval、date 或 hour 分组。颜色支持平滑或硬过渡,以及中间停靠值的插值。非数值状态可以通过 state_map 映射为标签,嵌套字典中的属性或属性可以通过点路径访问。 示例涵盖单实体、替代样式、多实体、柱状图、每周历史、仅图表卡片、水平堆叠、动态线条颜色、次级 y 轴、按日期分组、聚合函数、binary sensor 以及显示额外的仅状态实体。主题变量 --title-letter-spacing 和 --title-font-weight 允许自定义外观。开发需要 nodejs 和 npm,并提供 npm run build 和 npm run watch 脚本。