跳转到内容

每日总能量传感器

total_daily_energy 传感器是一个辅助传感器,可以使用其他传感器的功率值,如 HLW8012HLW8032CSE7766ATM90E32 等,并随时间对其进行积分。

因此,此组件允许您将 WkW 的读数转换为每日总能量使用量的 WhkWh 读数。

# 示例配置条目
sensor:
- platform: total_daily_energy
name: '每日总能量'
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 (可选, 布尔值): 是否在设备上存储中间结果,以便在断电或重启时可以恢复该值。默认为 true

  • method (可选, 字符串): 用于计算每日总能量的方法。可选值为 trapezoidleftright。默认为 right

  • 传感器的所有其他选项。

某些传感器(如 HLW8012)公开其功率传感器时使用 W 作为测量单位。要让您的读数以 kW 为单位,请使用过滤器:

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

对于此组件的更通用版本(不会在每天午夜重置),请参阅 积分传感器,它可以使用以下示例设置提供设备生命周期值而不是每日值:

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