Tuya switches with energy monitoring support

@ Bananaskin im using a docker image of Influxbd and grafana , to present this type of information.

Look like energy report is fully support by TUYA api. anyone can merge into home assistant switch.

https://github.com/codetheweb/tuyapi/issues/121

2 Likes

Has anyone tried it?

Wish to buy some tuya based plugs but only if the power reading is well calibrated, is updated fast , and easily integrated with HASS

I got about 10 of those tuya with power monitoring, different brand have different chipset. All of them converted to tasmota and self calibration is REQUIRED but not hard. Power change is update almost immediate via tasmota MQTT.
However, this feature request is to enable tuya power monitoring data to be accesible by home assistant not via tasmota.

I heard that now tuya-convert does not work anymore, did you flash them using the 4 pins?

Can anyone recommend EU power plugs that are easy to open/close (unscrew it without breaking the enlosure) in order to flash it with the 4 pins?

My goal is in order of preference

  1. find tuya-convert(ible) EU plugs
  2. find EU plugs easily flashable with Tasmota/ESPhome
  3. find EU plugs and use the tuya component but only when is possible fast and fast updated power monitoring

So far all 4 brand if have still flashable via tuya convert. Their are version 1.0.0 firmware.
Most brand does not update their firmware to block it. The company may not even exist anymore.

I am using all UK plug so i dont have recomendation for you

This page probably give you some flashable device but do check the tuya convert issue page before buying.

Hi, my two plugs arrived.

When I launch start_flash.sh

  1. it creates correctly vtrust-flash, and I connect it to the smartphone
  2. on the rapberry pi3 all seems ok, but I just see the dots …

maybe this cannot be flashed? How can I check ?

smarthack.web.log


e[33m[W 190708 11:25:33 web:2246]e[m 404 GET /api/333/config/wifi/ (127.0.0.1) 6.02ms
e[33m[W 190708 11:25:33 web:2246]e[m 404 PUT /api/333/config/wifi/updated (127.0.0.1) 6.54ms
e[33m[W 190708 11:25:33 web:2246]e[m 404 PUT /api/333/config/wifi/updated (127.0.0.1) 6.17ms
e[33m[W 190708 11:25:34 web:2246]e[m 404 PUT /api/333/config/wifi/updated (127.0.0.1) 6.05ms
e[33m[W 190708 11:25:34 web:2246]e[m 404 PUT /api/333/config/wifi/updated (127.0.0.1) 6.22ms
e[33m[W 190708 11:25:34 web:2246]e[m 404 GET /api/1CFA908992/groups?_=1562573480529 (192.168.1.3) 5.62ms
e[33m[W 190708 11:25:35 web:2246]e[m 404 GET /api/333/config/wifi/ (127.0.0.1) 5.87ms
e[33m[W 190708 11:25:35 web:2246]e[m 404 PUT /api/333/config/wifi/updated (127.0.0.1) 6.39ms
e[33m[W 190708 11:25:35 web:2246]e[m 404 PUT /api/333/config/wifi/updated (127.0.0.1) 6.47ms
e[33m[W 190708 11:25:35 web:2246]e[m 404 PUT /api/333/config/wifi/updated (127.0.0.1) 7.19ms
e[33m[W 190708 11:25:35 web:2246]e[m 404 PUT /api/333/config/wifi/updated (127.0.0.1) 6.28ms

in wifi log


Starting AP on wlan0 in screen terminal...
Configuration file: /etc/hostapd/hostapd.conf
wlan0: Could not connect to kernel driver
Using interface wlan0 with hwaddr b8:27:eb:xxxxxx and ssid "vtrust-flash"
wlan0: interface state UNINITIALIZED->ENABLED
wlan0: AP-ENABLED 
wlan0: STA 4c:49:e3:xxxx IEEE 802.11: associated
wlan0: AP-STA-CONNECTED 4c:49:e3:xxxx
wlan0: STA 4c:49:e3xxx RADIUS: starting accounting session 17F14F828CCxxxx
wlan0: STA 4c:49:e3:xxx WPA: pairwise key handshake completed (RSN)

Does the power plug needs to be put in normal pairing mode (blue led flash rapifdly) or in AP mode (blue led flash slowly)?

BTW both not work, I just get the dots waiting … and nothing else

I put in rapid flash mode.

once the script working there is dot even thing working behind… did you wait longer ?
Mine take about 30 - 40 dots before it proceeds

Yes I wait like 10 minutes.

Is there a way to understand if I am doing something wrong or the power plugs came with new firmware from factory and are not working anymore with Tuya-convert?

you have better luck asking in TUYA convert page. I dont know how to read tuyaconvert log

I got the energy-monitoring in HA with MQTT and Powermonitoring

https://pastebin.com/c3bh1zKi

1 Like

Nice finding.
I tried your method but i get this:

{“result”: “ERROR: No response from plug XXXX [IP].”}

Do i need to enter the key too?
I don’t see that in github repo, but i wonder if key is needed or not.

you are still passing the key variable, just explicit.
Would you mind to pastebin your .py file ( just edited the IP and ID ) ?
I changed plugpower.py the way you did ( maybe ) but i still get “No response from plug ID [IP]”.
I think the key must be passed with some plug, i have Koogeek plug running with smart life, maybe is that the “issue”.
Trying to run the whole script to save to MQTT and i get a value of “6153780” that is really wrong.

EDIT: are you editing plugpower.py or plugjson.py ? Cause seems plugjson.py in your image but you are using plugpower.py in your script :thinking:

You sure about the IP ?
Is it connected to 2.4ghz ?
Try type pyhton3 plugpower.py

i’m sure about it, same mac address that is in smart life, and it’s connected cause on home assistant i can control it with tuya and platform: smart_life :tipping_hand_man:
i’ll try to build the docker image to see if it helps ( not quite convinced ).
edit: same thing, not working, always no response. Maybe only some plugs can pass the default key, and some needs the right key, dunno.

Any chance you could give a quick guide to the steps necessary to get this setup and running in HA (hassbian if poss) ?

Thanks.

Here is my plugpower.py
http://m-hedqvist.nu/power/plugpower.py

Download plugpower from https://github.com/jasonacox/powermonitor

Change these two rows

Device Info - EDIT THIS

DEVICEID=“INPUTYOURDEVICE-ID”
DEVICEIP=“INPUTYOURIP”

Run the python-script
python3 plugpower.py

result should be

Polling Device XXX at 192.168.0.XX
Dictionary {‘devId’: ‘XXX’, ‘dps’: {‘1’: False, ‘9’: 0, ‘18’: 0, ‘19’: 0, ‘20’: 2275, ‘21’: 1, ‘22’: 635, ‘23’: 30333, ‘24’: 17521, ‘25’: 1190}}
Switch On: False

My device-id is like 46268374cc50e3******