视频教程:
https://youtu.be/vqvzF_mwM7E

更多视频教程请点这里

1.首先解析域名smartplugconnect.phicomm.com到你的Home Assistant 服务器。
——————————————————————————————
2.下载一个DC1网络配置工具安卓版本
DC1网络配置工具
——————————————————————————————
3.点此下载插件
再把附件放到.homeassistant/custom_components/下
—————————————————————————————-
4.配置文件增加如下配置(一个DC1插排):

switch:
  - platform: phicomm_dc1
    name: dc1
    ip: "192.168.2.116"   #修改此处为你的DC1 插排IP地址
    ports: {'1':'dc1_s1','2':'dc1_s2','3':'dc1_s3'}
  - platform: template
    switches:
      dc1_template:
        friendly_name: 总开关
        value_template: "{{ is_state('switch.dc1', 'on') }}"
        turn_on:
          service: switch.turn_on
          data:
            entity_id: switch.dc1
        turn_off:
          service: switch.turn_off
          data:
            entity_id: switch.dc1
      dc1_s1_template:
        friendly_name: 插座1
        value_template: "{{ is_state('switch.dc1_s1', 'on') }}"
        turn_on:
          service: switch.turn_on
          data:
            entity_id: switch.dc1_s1
        turn_off:
          service: switch.turn_off
          data:
            entity_id: switch.dc1_s1
      dc1_s2_template:
        friendly_name: 插座2
        value_template: "{{ is_state('switch.dc1_s2', 'on') }}"
        turn_on:
          service: switch.turn_on
          data:
            entity_id: switch.dc1_s2
        turn_off:
          service: switch.turn_off
          data:
            entity_id: switch.dc1_s2
      dc1_s3_template:
        friendly_name: 插座3
        value_template: "{{ is_state('switch.dc1_s3', 'on') }}"
        turn_on:
          service: switch.turn_on
          data:
            entity_id: switch.dc1_s3
        turn_off:
          service: switch.turn_off
          data:
            entity_id: switch.dc1_s3
sensor:
  - platform: template
    sensors:
      dc1_v:
        friendly_name: 当前电压
        value_template: "{{ states.switch.dc1.attributes.v }}"
        unit_of_measurement: V
      dc1_p:
        friendly_name: 当前功率
        value_template: "{{ states.switch.dc1.attributes.p }}"
        unit_of_measurement: W
      # dc1_totale:
      #   friendly_name: 累计用电
      #   value_template: "{{ states.switch.dc1.attributes.totalelect }}"
      #   unit_of_measurement: 度
group:
  dc1:
    name: 工作区DC1排插
    view: no
    entities:
      - sensor.dc1_v
      - sensor.dc1_p
      #- sensor.dc1_totale
      - switch.dc1_template
      - switch.dc1_s1_template
      - switch.dc1_s2_template
      - switch.dc1_s3_template

homeassistant:
customize:
# Add an entry for each entity that you want to overwrite.
switch.dc1:
hidden: true
switch.dc1_s1:
hidden: true
switch.dc1_s2:
hidden: true
switch.dc1_s3:
hidden: true

配置文件增加如下配置(两个DC1插排):

switch:
  - platform: phicomm_dc1
    name: dc1
    ip: "192.168.2.116"  #修改此处为你的DC1 插排IP地址
    ports: {'1':'dc1_s1','2':'dc1_s2','3':'dc1_s3'}
  - platform: phicomm_dc1
    name: dc1_2
    ip: "192.168.2.122"  #修改此处为你的DC1 插排IP地址
    ports: {'1':'dc1_2_s1','2':'dc1_2_s2','3':'dc1_2_s3'}
  - platform: template
    switches:
      dc1_template:
        friendly_name: 总开关
        value_template: "{{ is_state('switch.dc1', 'on') }}"
        turn_on:
          service: switch.turn_on
          data:
            entity_id: switch.dc1
        turn_off:
          service: switch.turn_off
          data:
            entity_id: switch.dc1
      dc1_s1_template:
        friendly_name: 插座1
        value_template: "{{ is_state('switch.dc1_s1', 'on') }}"
        turn_on:
          service: switch.turn_on
          data:
            entity_id: switch.dc1_s1
        turn_off:
          service: switch.turn_off
          data:
            entity_id: switch.dc1_s1
      dc1_s2_template:
        friendly_name: 插座2
        value_template: "{{ is_state('switch.dc1_s2', 'on') }}"
        turn_on:
          service: switch.turn_on
          data:
            entity_id: switch.dc1_s2
        turn_off:
          service: switch.turn_off
          data:
            entity_id: switch.dc1_s2
      dc1_s3_template:
        friendly_name: 插座3
        value_template: "{{ is_state('switch.dc1_s3', 'on') }}"
        turn_on:
          service: switch.turn_on
          data:
            entity_id: switch.dc1_s3
        turn_off:
          service: switch.turn_off
          data:
            entity_id: switch.dc1_s3
	   
      dc1_2_template:
        friendly_name: 总开关
        value_template: "{{ is_state('switch.dc1', 'on') }}"
        turn_on:
          service: switch.turn_on
          data:
            entity_id: switch.dc1
        turn_off:
          service: switch.turn_off
          data:
            entity_id: switch.dc1
      dc1_2_s1_template:
        friendly_name: 插座3
        value_template: "{{ is_state('switch.dc1_s1', 'on') }}"
        turn_on:
          service: switch.turn_on
          data:
            entity_id: switch.dc1_2_s1
        turn_off:
          service: switch.turn_off
          data:
            entity_id: switch.dc1_2_s1
      dc1_2_s2_template:
        friendly_name: 插座4
        value_template: "{{ is_state('switch.dc1_s2', 'on') }}"
        turn_on:
          service: switch.turn_on
          data:
            entity_id: switch.dc1_2_s2
        turn_off:
          service: switch.turn_off
          data:
            entity_id: switch.dc1_2_s2
      dc1_2_s3_template:
        friendly_name: 插座5
        value_template: "{{ is_state('switch.dc1_s3', 'on') }}"
        turn_on:
          service: switch.turn_on
          data:
            entity_id: switch.dc1_2_s3
        turn_off:
          service: switch.turn_off
          data:
            entity_id: switch.dc1_2_s3
sensor:
  - platform: template
    sensors:
      dc1_v:
        friendly_name: 当前电压
        value_template: "{{ states.switch.dc1.attributes.v }}"
        unit_of_measurement: V
      dc1_p:
        friendly_name: 当前功率
        value_template: "{{ states.switch.dc1.attributes.p }}"
        unit_of_measurement: W
      dc1_2_v:
        friendly_name: 当前电压
        value_template: "{{ states.switch.dc1_2.attributes.v }}"
        unit_of_measurement: V
      dc1_2_p:
        friendly_name: 当前功率
        value_template: "{{ states.switch.dc1_2.attributes.p }}"
        unit_of_measurement: W
      # dc1_totale:
      #   friendly_name: 累计用电
      #   value_template: "{{ states.switch.dc1.attributes.totalelect }}"
      #   unit_of_measurement: 度
group:
  dc1:
    name: 工作区DC1排插
    view: no
    entities:
      - sensor.dc1_v
      - sensor.dc1_p
      #- sensor.dc1_totale
      - switch.dc1_template
      - switch.dc1_s1_template
      - switch.dc1_s2_template
      - switch.dc1_s3_template
  dc1_2:
    name: DC1排插2
    view: no
    entities:
      - sensor.dc1_2_v
      - sensor.dc1_2_p
      #- sensor.dc1_totale
      - switch.dc1_2_template
      - switch.dc1_2_s1_template
      - switch.dc1_2_s2_template
      - switch.dc1_2_s3_template
homeassistant:        
  customize:
    # Add an entry for each entity that you want to overwrite.
    switch.dc1:
      hidden: true
    switch.dc1_s1:
      hidden: true
    switch.dc1_s2:
      hidden: true
    switch.dc1_s3:
      hidden: true

36 对 “斐讯DC1 插排接入Home Assistant (0.93版本)”的想法;

  1. 按照你的教程看了几遍了,我用手机APP配置了DC1。灯也变了,但是,我怎么知道DC1的IP地址呢?视频没有交代,请多指教,谢谢!

    1. 你可以从路由器上看到DC1的IP地址,路由器的DHCP池里可以看到,如果不确定是哪个地址,你可以ping配合插拔电源来测试是不是这个地址。

      1. 地址池了找到了PHICOMM_9E16F0,然后按照你的步骤试了,还是不行,还有一个问题,这个版本有packages文件夹吗,版本太多,而且很多教程,搞晕了。我的是0.93版本。

  2. up主,我(小白)经过看你的视频,经过多次研究才测试成功。因为你视频里讲的一处,是把configuration.yaml删掉,我照着做hass无法启动了。然后把原来备份的configuration.yaml恢复,再把switch:…那段代码复制再configuration.yaml里(原configuration.yaml不动,接下去复制)后才成功,而且底下的那一小部分因为直接复制格式,导致没有空格,不符合pytho*格式报错,加上python的空格纠正格式后,可以正常控制了。纠正!!!

  3. 老师,您好,小白,第一次弄,树莓派64位镜像,集成DOCKER版本OPENWRT,还有HOME ASSISTANT。安装了以上版本系统,集成home assistant,按您去年那篇文章https://sumju.net/?p=685配置DC1,提示没有那个路径,这个版本的配置路径改为哪个路径,该怎么设置呢?请指导,重装了好几次系统,没成功,求指导。谢谢!

  4. 这些代码是不是只能使用在HA 0.93版本上面,我现在是N1上面docker安装的hassio,HA的版本好像是0.103吧。运行不成功啊。HA配置检查,总是出错。难道一定要0.93。难道HA还不能升级了吗??

  5. 2个插排调试情况:
    configuration.yaml里面,遇到DC1 脚本配置大类两处与老脚本同类的,如何让新老脚本合法执行呢,
    我改了两次,把原有sensor 与 switch 老脚本剪切到 新脚本同类下部,这样处理:#sensor 与 #switch,
    提交后重启进入hass,所以插件消失,进入安全状态:
    2020-05-05 00:16:54 ERROR (SyncWorker_1) [homeassistant.util.yaml.loader] while scanning for the next token
    found character ‘\t’ that cannot start any token
    in “/config/configuration.yaml”, line 152, column 1
    2020-05-05 00:16:54 ERROR (MainThread) [homeassistant.bootstrap] Failed to parse configuration.yaml: while scanning for the next token
    found character ‘\t’ that cannot start any token
    in “/config/configuration.yaml”, line 152, column 1. Falling back to safe mode
    2020-05-05 00:17:14 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
    2020-05-05 01:01:26 WARNING (MainThread) [homeassistant.components.webhook] Received message for unregistered webhook 5d2a494311dd4893a464c0b31e64f392314f4f76137cc4eda911bf1825c30207
    2020-05-05 01:01:26 WARNING (MainThread) [homeassistant.components.webhook] Received message for unregistered webhook 5d2a494311dd4893a464c0b31e64f392314f4f76137cc4eda911bf1825c30207
    2020-05-05 01:01:27 WARNING (MainThread) [homeassistant.components.webhook] Received message for unregistered webhook 5d2a494311dd4893a464c0b31e64f392314f4f76137cc4eda911bf1825c30207
    只能把备份的yaml恢复,,,,,,,

  6. 通过阅读上面的系统警告提示:found character ‘\t’ that cannot start any token in “/config/configuration.yaml”, line 152, column
    操作:xshell —-》修改152上下文有空格,删除空格,保持语法连贯。
    HASS重启后界面回复正常。插件都有了。

  7. 感谢分享教程,已经成功。但是现在有个蛋疼的问题,dc1在WIFI重启之后不会自动连接WIFI,用的是k2p刷了chongshengb的padavan固件,只能手动把插座断电再插电或者重复一遍配网操作。请问帖主有没有办法解决?

发表回复

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据