『瀚思彼岸』» 智能家居技术论坛

标题: 【已解决】系统更新后DC1电压功率无法获取 [打印本页]

作者: xkx6149    时间: 2022-4-12 11:59
标题: 【已解决】系统更新后DC1电压功率无法获取
本帖最后由 xkx6149 于 2023-6-9 14:22 编辑
sensor:
  - platform: template
    sensors:
      dc1_1_v:
        friendly_name: 当前电压
        value_template: "{{ states.switch.dc1_1.attributes.v }}"
        unit_of_measurement: V
      dc1_1_p:
        friendly_name: 当前功率
        value_template: "{{ states.switch.dc1_1.attributes.p }}"
        unit_of_measurement: W

报错如下:

Logger: homeassistant.helpers.template
Source: helpers/template.py:1828
First occurred: 11:26:27 (12 occurrences)
Last logged: 11:26:27

Template variable warning: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'p' when rendering '{{ states.switch.dc1_1.attributes.p }}'
Template variable warning: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'v' when rendering '{{ states.switch.dc1_1.attributes.v }}'

请问大佬如何修复

作者: bainiu    时间: 2022-4-13 00:15
我的dc1没有问题,硬刷的情留蚊子大佬的固件。你看看mqtt里,订阅的信息是否有。
作者: xkx6149    时间: 2022-4-13 19:10
bainiu 发表于 2022-4-13 00:15
我的dc1没有问题,硬刷的情留蚊子大佬的固件。你看看mqtt里,订阅的信息是否有。 ...

我懒,直接劫持的
作者: lwn    时间: 2022-4-19 18:26
需要把 switch.py里的 device_state_attributes 改成 extra_state_attributes

见:
https://developers.home-assistan ... #generic-properties
作者: xkx6149    时间: 2022-4-20 10:48
lwn 发表于 2022-4-19 18:26
需要把 switch.py里的 device_state_attributes 改成 extra_state_attributes

见:

已解决,非常感谢!




欢迎光临 『瀚思彼岸』» 智能家居技术论坛 (https://bbs.hassbian.com/) Powered by Discuz! X3.5