HA集成国家电网来查看用电信息
1.登陆HA后需要点击设置—>应用—>安装应用。右上角有仓库选项,添加自定义仓库。

💡仓库地址如下
https://github.com/ARC-MX/sgcc_electricity_new

2.添加完成后就可以看到SGCC Electricity

3.进入SGCC后,点击配置,修改如下配置选项。

- PHONE_NUMBER,PHONE_NUMBER 为自己的手机号和密码,此账号为国家电网官网登录账户。
- HASS_URL: 修改为本地HA的IP地址
- HASS_TOKEN :预先新建TOKEN,粘贴到这里。如何新建TOKEN属于HA基础操作,不在这里赘述。
💡作者使用了硅基流动的多模态模型,您可以使用如下邀请链接https://cloud.siliconflow.cn/i/EEsY3bbw获得16元体验卷(对于当前应用设置的更新频率,至少可以使用2年)。当然您也可以使用其他的模型服务提供商的模型服务。这里使用模型服务的目的是在登录国家电网过程中自动识别图形验证码,所以为必选项。
- LLM_API_KEY :如果您也使用硅基流动的多模态模型,可以在硅基流动官网页面创建API密钥,然后黏贴至此字段。

- LLM_BASE_URL:https://api.siliconflow.cn/v1
- LLM_MODEL:Qwen/Qwen3.5-35B-A3B
4.正常配置完成后点击日志,可以看到登录成功。

5.在HACS中安装Lovelace Mini Graph Card,然后新建卡片贴贴如下代码,将卡片信息展示在前端页面。
type: vertical-stack
cards:
- type: custom:mini-graph-card
entities:
- entity: sensor.last_electricity_usage_3084
name: 国网每日用电量
aggregate_func: first
show_state: true
show_points: true
icon: mdi:lightning-bolt-outline
- entity: sensor.electricity_charge_balance_3084
name: 电费余额
aggregate_func: first
show_state: true
show_points: true
color: "#e74c3c"
icon: mdi:cash
y_axis: secondary
group_by: date
hour24: true
hours_to_show: 240
lower_bound: 0
upper_bound: 10
lower_bound_secondary: 0
upper_bound_secondary: 120
show:
icon: false
- type: horizontal-stack
cards:
- graph: none
type: sensor
entity: sensor.month_electricity_charge_3084
detail: 1
name: 上月电费
icon: ""
unit: 元
- graph: none
type: sensor
entity: sensor.month_electricity_usage_3084
detail: 1
name: 上月用电量
unit: 度
icon: mdi:lightning-bolt-outline
- type: horizontal-stack
cards:
- animate: true
entities:
- entity: sensor.yearly_electricity_usage_3084
name: 今年总用电量
aggregate_func: first
show_state: true
show_points: true
group_by: date
hour24: true
hours_to_show: 240
type: custom:mini-graph-card
- animate: true
entities:
- entity: sensor.yearly_electricity_charge_3084
name: 今年总用电费用
aggregate_func: first
show_state: true
show_points: true
group_by: date
hour24: true
hours_to_show: 240
type: custom:mini-graph-card

