Closed ooodwbooo closed 1 year ago
能源看板配置添加用电数据 其中并没有添加的传感器
用电数据要怎么添加啊,配置文件如下
# Loads default set of integrations. Do not remove. default_config: # Load frontend themes from the themes folder frontend: themes: !include_dir_merge_named themes automation: !include automations.yaml script: !include scripts.yaml scene: !include scenes.yaml # 文件中只能有一个sensor sensor: # 实时电价 - platform: template #平台名称 sensors: #传感器列表 real_time_electricity_price: #实体名称:只能用小写,下划线 unique_id: "real_time_electricity_price" #UID(必须) friendly_name: '实时电价' #在前端显示的传感器昵称(可选) unit_of_measurement: "CNY/kWh" #传感器数值的单位(可选) icon_template: mdi:currency-jpy #默认图标 value_template: > #定义一个获取传感器状态的模板(必须)下面的6和22是指6点和22点,"1""2""3"是指阶梯123,6个价格分别是3个阶梯的峰谷价格 {% if now().strftime("%H")| int >= 6 and now().strftime("%H")|int < 22 and states("sensor.current_ladder")=="1" %} 0.617 {%elif now().strftime("%H")| int >= 6 and now().strftime("%H")|int < 22 and states("sensor.current_ladder")=="2" %} 0.677 {%elif now().strftime("%H")| int >= 6 and now().strftime("%H")|int < 22 and states("sensor.current_ladder")=="3" %} 0.977 {% elif states("sensor.current_ladder")=="1" %} 0.307 {% elif states("sensor.current_ladder")=="2" %} 0.337 {% elif states("sensor.current_ladder")=="3" %} 0.487 {% endif %} # 当前阶梯 - platform: template sensors: current_ladder: unique_id: "current_ladder" friendly_name: '当前阶梯' unit_of_measurement: "级" icon_template: mdi:elevation-rise value_template: > #这里是上海的三个阶梯数值,第2阶梯3120,第三阶梯4800 {% if states("sensor.yearly_electricity_usage_entity") | float <= 3120 %} 1 {% elif states("sensor.yearly_electricity_usage_entity") | float >3120 and states("sensor.yearly_electricity_usage_entity") | float <= 4800 %} 2 {% else %} 3 {% endif %} template: # 参考文档: https://www.home-assistant.io/integrations/template - trigger: - platform: event event_type: "state_changed" event_data: entity_id: sensor.electricity_charge_balance sensor: - name: electricity_charge_balance_entity unique_id: electricity_charge_balance_entity state: "{{ states('sensor.electricity_charge_balance') }}" state_class: total unit_of_measurement: "CNY" device_class: monetary - trigger: - platform: event event_type: "state_changed" event_data: entity_id: sensor.last_electricity_usage sensor: - name: last_electricity_usage_entity unique_id: last_electricity_usage_entity state: "{{ states('sensor.last_electricity_usage') }}" attributes: present_date: "{{ state_attr('sensor.last_electricity_usage', 'present_date') }}" last_updated: "{{ state_attr('sensor.last_electricity_usage', 'last_updated') }}" state_class: measurement unit_of_measurement: "kWh" device_class: energy - trigger: - platform: event event_type: "state_changed" event_data: entity_id: sensor.yearly_electricity_usage sensor: - name: yearly_electricity_usage_entity unique_id: yearly_electricity_usage_entity state: "{{ states('sensor.yearly_electricity_usage') }}" state_class: total unit_of_measurement: "kWh" device_class: energy - trigger: - platform: event event_type: "state_changed" event_data: entity_id: sensor.yearly_electricity_charge sensor: - name: yearly_electricity_charge_entity unique_id: yearly_electricity_charge_entity state: "{{ states('sensor.yearly_electricity_charge') }}" state_class: total unit_of_measurement: "CNY" device_class: monetary
我找到问题了,数据单位有一部分是KWH,K大写了单位必须是kWh,小写k
能源看板配置添加用电数据 其中并没有添加的传感器
用电数据要怎么添加啊,配置文件如下