1.China Southern Power Grid Statistics集成
2.获取当月用电情况

因为我的电费是固定的,没有阶梯电价
用电量 * 0.63906875 = 电费
3.计算电费然后在UI上显示
进入configuration.yaml,添加以下代码
homeassistant:
customize: !include customize.yaml
sensor:
- platform: template
sensors:
electricity_bill:
friendly_name: "当月电费"
unit_of_measurement: '¥' # Replace with your currency unit, like '$', '€', etc.
value_template: "{{ (states('sensor.0*****************7_this_month_total_usage') | float * 0.63906875) | round(2) }}"
sensor.0*****************7_this_month_total_usage修改成你自己的实体ID

在customize.yaml里添加下面代码 这部分是修改图标,显示¥
sensor.electricity_bill:
icon: mdi:currency-cny

保存,重启以下配置!
3.效果
搜索 electricity_bill实体

文章介绍了如何将ChinaSouthernPowerGridStatistics集成到HomeAssistant中,通过获取当月用电量并乘以固定费率来计算电费,然后在用户界面(UI)上展示。具体步骤包括编辑configuration.yaml和customize.yaml文件,设置传感器模板以及修改图标以显示货币单位。
2353





