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

 找回密码
 立即注册
查看: 3348|回复: 4

[技术探讨] 有关计量电表

[复制链接]

2

主题

109

帖子

763

积分

高级会员

Rank: 4

积分
763
金钱
654
HASS币
0
发表于 2020-10-7 10:29:08 | 显示全部楼层 |阅读模式
本帖最后由 vvlang 于 2020-10-7 10:33 编辑


这种计量电表有人做成了吗?
用tuya-convert刷进去tasmota
或者线刷
esptool.py --port COM3 --baud 74880 --after no_reset write_flash --flash_size 1MB --flash_mode dio 0x00000 tuya_backup.bin --erase-all
zmai-90-generic-module-io-settings_02.png
- platform: mqtt
    name: "Mains Consumed Energy"
    state_topic: "tele/general-meter-switch/RESULT"
    value_template: >- 
      {% set message = value_json.SerialReceived %}
      {% set payload = message[6:14] %}
      {% set payload_len = (payload | length) %}
      {% set result = namespace(value='') %}
      
      {% for i in range(0, payload_len + 1) | reverse -%}
        {%- if i is divisibleby 2 -%}
          {%- set result.value = result.value + payload[i:i+2] -%}
        {%- endif -%}
      {%- endfor -%}
      
      {{ (result.value|float) / 100 }}
    unit_of_measurement: 'kWh'    
  - platform: mqtt
    name: "Mains Voltage"
    state_topic: "tele/general-meter-switch/RESULT"
    value_template: >- 
      {% set message = value_json.SerialReceived %}
      {% set payload = message[14:22] %}
      {% set payload_len = (payload | length) %}
      {% set result = namespace(value='') %}
      
      {% for i in range(0, payload_len + 1) | reverse -%}
        {%- if i is divisibleby 2 -%}
          {%- set result.value = result.value + payload[i:i+2] -%}
        {%- endif -%}
      {%- endfor -%}
      
      {{ (result.value|float) / 10 }}
    unit_of_measurement: 'Volts'
  - platform: mqtt
    name: "Mains Current"
    state_topic: "tele/general-meter-switch/RESULT"
    value_template: >- 
      {% set message = value_json.SerialReceived %}
      {% set payload = message[22:30] %}
      {% set payload_len = (payload | length) %}
      {% set result = namespace(value='') %}
      
      {% for i in range(0, payload_len + 1) | reverse -%}
        {%- if i is divisibleby 2 -%}
          {%- set result.value = result.value + payload[i:i+2] -%}
        {%- endif -%}
      {%- endfor -%}
      
      {{ (result.value|float) / 10000 }}
    unit_of_measurement: 'Amps'
  - platform: mqtt
    name: "Mains Frequency"
    state_topic: "tele/general-meter-switch/RESULT"
    value_template: >- 
      {% set message = value_json.SerialReceived %}
      {% set payload = message[30:38] %}
      {% set payload_len = (payload | length) %}
      {% set result = namespace(value='') %}
      
      {% for i in range(0, payload_len + 1) | reverse -%}
        {%- if i is divisibleby 2 -%}
          {%- set result.value = result.value + payload[i:i+2] -%}
        {%- endif -%}
      {%- endfor -%}
      
      {{ (result.value|float) / 100 }}
    unit_of_measurement: 'Hz'
  - platform: mqtt
    name: "Mains Active Power"
    state_topic: "tele/general-meter-switch/RESULT"
    value_template: >- 
      {% set message = value_json.SerialReceived %}
      {% set payload = message[38:46] %}
      {% set payload_len = (payload | length) %}
      {% set result = namespace(value='') %}
      
      {% for i in range(0, payload_len + 1) | reverse -%}
        {%- if i is divisibleby 2 -%}
          {%- set result.value = result.value + payload[i:i+2] -%}
        {%- endif -%}
      {%- endfor -%}
      
      {{ (result.value|float) / 100 }}
    unit_of_measurement: 'Watts'    
  - platform: mqtt
    name: "Mains Reactive Power"
    state_topic: "tele/general-meter-switch/RESULT"
    value_template: >- 
      {% set message = value_json.SerialReceived %}
      {% set payload = message[46:54] %}
      {% set payload_len = (payload | length) %}
      {% set result = namespace(value='') %}
      
      {% for i in range(0, payload_len + 1) | reverse -%}
        {%- if i is divisibleby 2 -%}
          {%- set result.value = result.value + payload[i:i+2] -%}
        {%- endif -%}
      {%- endfor -%}
      
      {{ (result.value|float) / 100 }}
    unit_of_measurement: 'Watts'      
  - platform: mqtt
    name: "Mains Apparent Power"
    state_topic: "tele/general-meter-switch/RESULT"
    value_template: >- 
      {% set message = value_json.SerialReceived %}
      {% set payload = message[54:62] %}
      {% set payload_len = (payload | length) %}
      {% set result = namespace(value='') %}
      
      {% for i in range(0, payload_len + 1) | reverse -%}
        {%- if i is divisibleby 2 -%}
          {%- set result.value = result.value + payload[i:i+2] -%}
        {%- endif -%}
      {%- endfor -%}
      
      {{ (result.value|float) / 100 }}
    unit_of_measurement: 'Watts'
  - platform: mqtt
    name: "Mains Power Factor"
    state_topic: "tele/general-meter-switch/RESULT"
    value_template: >- 
      {% set message = value_json.SerialReceived %}
      {% set payload = message[62:70] %}
      {% set payload_len = (payload | length) %}
      {% set result = namespace(value='') %}
      
      {% for i in range(0, payload_len + 1) | reverse -%}
        {%- if i is divisibleby 2 -%}
          {%- set result.value = result.value + payload[i:i+2] -%}
        {%- endif -%}
      {%- endfor -%}
      
      {{ (result.value|float) / 10 }}
    unit_of_measurement: '%'


回复

使用道具 举报

40

主题

3056

帖子

1万

积分

超级版主

Nero

Rank: 8Rank: 8

积分
11149
金钱
8042
HASS币
182
发表于 2020-10-7 11:07:43 | 显示全部楼层
没看懂,帖子没头没尾的~
Nero
回复

使用道具 举报

2

主题

109

帖子

763

积分

高级会员

Rank: 4

积分
763
金钱
654
HASS币
0
 楼主| 发表于 2020-10-7 19:46:28 | 显示全部楼层
neroxps 发表于 2020-10-7 11:07
没看懂,帖子没头没尾的~

把电表ZMAi-90接入到homeassistant
回复

使用道具 举报

40

主题

3056

帖子

1万

积分

超级版主

Nero

Rank: 8Rank: 8

积分
11149
金钱
8042
HASS币
182
发表于 2020-10-8 09:02:45 | 显示全部楼层
vvlang 发表于 2020-10-7 19:46
把电表ZMAi-90接入到homeassistant

哦 这个是接进去的配置是吧?
Nero
回复

使用道具 举报

2

主题

109

帖子

763

积分

高级会员

Rank: 4

积分
763
金钱
654
HASS币
0
 楼主| 发表于 2020-10-10 20:23:30 | 显示全部楼层
neroxps 发表于 2020-10-8 09:02
哦 这个是接进去的配置是吧?

对的,在homeassistant里面的配置
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-11-26 12:38 , Processed in 0.053066 second(s), 30 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表