本帖最后由 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
- 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: '%'
|