|
发表于 2023-8-1 17:49:21
|
显示全部楼层
针对只有一个实体(electricity_95598)的,
使用下面的配置
template:
- trigger:
- platform: event
event_type: "state_changed"
event_data:
entity_id: sensor.electricity_95598
sensor:
- name: electricity_charge_balance_entity
unique_id: electricity_charge_balance_entity
state: "{{ states('sensor.electricity_95598') }}"
state_class: measurement
unit_of_measurement: "CNY"
device_class: monetary
- trigger:
- platform: event
event_type: "state_changed"
event_data:
entity_id: sensor.electricity_95598
sensor:
- name: last_electricity_usage_entity
unique_id: last_electricity_usage_entity
state: "{{ state_attr('sensor.electricity_95598', 'last_electricity_usage') }}"
state_class: total_increasing
unit_of_measurement: "kWh"
device_class: energy
- trigger:
- platform: event
event_type: "state_changed"
event_data:
entity_id: sensor.electricity_95598
sensor:
- name: yearly_electricity_usage_entity
unique_id: yearly_electricity_usage_entity
state: "{{ state_attr('sensor.electricity_95598', 'yearly_electricity_usage') }}"
state_class: total_increasing
unit_of_measurement: "kWh"
device_class: energy
- trigger:
- platform: event
event_type: "state_changed"
event_data:
entity_id: sensor.electricity_95598
sensor:
- name: thismonth_electricity_usage_entity
unique_id: thismonth_electricity_usage_entity
state: "{{ state_attr('sensor.electricity_95598', 'thismonth_electricity_usage') }}"
state_class: total_increasing
unit_of_measurement: "kWh"
device_class: energy
- trigger:
- platform: event
event_type: "state_changed"
event_data:
entity_id: sensor.electricity_95598
sensor:
- name: yearly_electricity_charge_entity
unique_id: yearly_electricity_charge_entity
state: "{{ state_attr('sensor.electricity_95598', 'yearly_electricity_charge') }}"
state_class: total_increasing
unit_of_measurement: "CNY"
device_class: monetary
|
|