跳转到内容

每日总能耗传感器

total_daily_energy 传感器是一个辅助传感器,可使用其他传感器(如 HLW8012、HLW8032、CSE7766、ATM90E32 等)的功率值,并随时间进行积分。

因此,该组件允许您将 W 或 kW 的读数转换为每日总能耗的 Wh 或 kWh 读数。

# 示例配置条目
sensor:
- platform: total_daily_energy
name: 'Total Daily Energy'
power_id: my_power
unit_of_measurement: 'kWh'
state_class: total_increasing
device_class: energy
accuracy_decimals: 3
filters:
# 从 W 转换为 kW 的乘数因子为 0.001
- multiply: 0.001
# 要转换的功率传感器,可以是任意功率传感器
- platform: hlw8012
# ...
power:
id: my_power
# 启用时间组件以在午夜重置能耗
time:
- platform: homeassistant
id: homeassistant_time
  • power_id (必选, ID): 需要随时间进行积分的功率传感器的 ID。

  • restore (可选, boolean): 是否在设备上存储中间结果,以便在断电或重启时恢复数值。默认为 true。

  • method (可选, string): 用于计算每日总能耗的方法。可选值为 trapezoid、left 或 right。默认为 right。

  • Sensor 的所有其他选项。

一些传感器(如 HLW8012)会以 W 为单位公开功率传感器。如需以 kW 为单位获取读数,请使用过滤器:

sensor:
# 要转换的功率传感器,可以是任意功率传感器
- platform: hlw8012
# ...
power:
id: my_power
filters:
# 从 W 转换为 kW 的乘数因子为 0.001
- multiply: 0.001
unit_of_measurement: kW

如果您需要一个更通用的版本(不在每天午夜重置),请参见 Integration,它可以使用以下示例设置提供设备寿命值而非每日值:

# 示例配置条目
sensor:
- platform: integration
name: 'Total Energy'
sensor: my_power
time_unit: h
restore: true
state_class: total_increasing
device_class: energy