Energy consumption and Arlec Grid Connect (Tuya) smart plug

Hi. See my post at the bottom. Add a line to the yaml file
method: left

This is needed for on/off heaters.

You can see the effect in the last hour.

No problem - glad it’s working for you as well! As for the copy and paste thing - there shouldn’t have been any hidden characters but it may very well have been a formatting issue. It’s so easy for a space or tab to creep into a yaml file and break it - which why I got into the habit of always testing my code after any change no matter how minor… :slight_smile:

i have ten power sockets but does show me only one power reding any advice to see all the plugs working?

Assuming you are using the new Tuya integration then it will create ten switches and each switch will have separate sensors. To see them in the energy section have you created ten extra sensors as described above?

i already do all the steps but it still does not show me the power readings,
it’s so odd

Oooh. Was in Bunnings yesterday and found this “Arlec Grid Connect Smart IP44 Heavy Duty Timer”. It is designed to plug into an external power point, and it does energy monitoring. Cost AUD$25. Bought one to play with, and:

  • Connected it to my wifi via the Smart Life app
  • Went to hassio, reloaded the Tuya integration, and the new device was there
  • Still in hassio, went into the integration and enabled the three additional sensors
  • Once the sensors were available, I then checked the name of the power sensor which in my case was “sensor.pc44ha_power” and of course reporting power usage in W.
  • Then edited my sensor.yaml file and added:
  - platform: integration
    source: sensor.pc44ha_power
    name: Pool Fridge Energy
    unit_prefix: k
    round: 2  

After a little while, my new power monitor for the pool fridge was available to add into my energy monitoring. Yay!

Coul you please share configiration.yaml and sensor.yaml file?

Hi. Literally it is the message above. Basically you need to setup the Tuya integration (as described here: Tuya - Home Assistant), then when you add devices in via the Tuya Smart Life app, those devices that are supported will simply appear in home assistant enabling you to turn them on/off etc. The power sensors may not appear, in which case you need to enable them (as mentioned above - it’s just done via the home assistant web interface). If you want to monitor power usage over time via the ‘Energy’ tab in home assistant you can create a sensor that tracks the instant W readings to kW over time via “platform: integration” as shown above - that’s the only yaml editing you need to do, and that is in your sensor section in configuration.yaml or - if you pulled them all into a separate sensor.yaml file - in sensor.yaml.

1 Like

FYI, I bought a 4-pack of the Arlec Smart plug-in socket with energy meter (model PC191HA) from Bunnings for Aus$65.oo.
I followed instructions in the video at Get your Tuya Device Local Key - YouTube to get the Local key and Device specification attributes:

Having installed in the Tuya phone app, I used my router to associate the device MAC addresses to specific IP addresses (which happen to be blocked by the firewall).

I have installed each using the TuyaLoacal integration:

  1. Select the new device from Device ID or IP Address, with Platform of “switch” then as shown:

    plus dp_id 20 for Voltage.
  2. UN-tick the “Do not add any more entities” box, select “number”, Submit, then select dp_id of 9, name “countdown” and range 0 to 86400 (from memory, number of seconds in 1 day).
  3. Same for dp_id 38, relay_status with enumerated values “off”, “on”, and “last”.
  4. no more entities to add, so leave the “Do not add any more entities” box ticked.

The switch works, as does the countdown timer. The relay_status does not - but I can live without it for now.

I see current, current_consumption and voltage values are attributes of the “switch” entities - however they aren’t automagically made available to report on.

I had to add the YAML code from the “Energy monitoring values” section of LocalTuya documentation to my HA configuration.yaml, and they are now reporting correctly (using the custom:multiple-entity-row frontend available in HACS)
Screenshot from 2022-05-25 19-20-44

1 Like

I also recently bought a bunnings 4-pack of these AC plugs.

Thanks to your help I’ve got it to the point where it can be controlled on/off, and report Current / Power / Voltage correctly.

I’d love to be able to accurately measure the electricity usage over time, which the Tuya app can do, and I noticed one of the device attributes is “add_ele”

Which monitored over time, does change value:


It says that it is measured in kW.h, with a scale of “3” and a step of “100”
…whatever that means

Maybe someone out there with better understanding, and some good math’s can turn this value into a energy consumption meter? :wink:

I think You need to convert to kWh then run a utility meter for the daily sum. This will then usable in the energy dashboard.

#Convert W on the GPO's to kWh
  - platform: integration
    source: sensor.po_master_bed_power
    name: po_master_bed_power_k
    unit_prefix: k
    round: 2
    method: left  

    source: sensor.po_master_bed_power_k
    name: PO Master BED kWh Daily
    cycle: daily
1 Like

Great info.

I also have a number of these devices integrated into Home Assistant using Local Tuya.

Yesterday I plugged another into a pool pump to measure its usage.
All working well but noticed something very odd regarding the Current details provided.

The current output is incorrect, this isn’t just isolated to Home Assistant but also to the Smart Life App/Tuya.

Comparing your figures above also show the incorrect value for charger device.
Your dinning_table values seem to be correct.

ie: 240volt using 5.7W should be around 0.023amps not 0.07a

Any idea what firmware your devices are on?


Sorry, but I don’t feel able to answer your queries :frowning:

In the image I posted above, “charger” and “dining_table” were using TP-Link Kasa plugs (which report Amps rather than milliAmps). Since then I have rearranged where each plug is used, and separated fridge/freezers and washer/drier onto separate lovelace cards to make the comparisons more consistent.

I have also found that my wi-fi AP only allows 15 devices connected, so some have been dropping off from time to time.

Moreover I found that my PC191HA switches are always showing Voltage, but only sometimes show non-zero values for Current and Amps; as described in this post.

I am currently waiting for a drayTek AP802 (32 wifi connections per band); and intend to do more thorough testing once all has settled down. Renaming devices has of course also played havoc with HA history, and I’m wondering if it’s a good time to start from scratch again on a new SD card.

I have two of these (2x different models), unfortunately they arent very sensitive at low power consumption (IE, 5w lights).
Recommend if you do use them, target your larger applicances (fridge, washing machine, etc).

Thanks for that bit of code, was wondering how to do that.

It seems the plug logs it’s usage every 30mins, but Home Assistant isn’t getting these numbers as reliably through local tuya.

You’re method would work, if maybe every 30 mins a script can request their “add_elec” value directly from the AC plug, but I don’t know if that’s possible :slight_smile:

It took me some time to figure out how to get the current, power, voltage setup as sensors rather than the default attributes with Tuya Loca with the Arlec Grid connect plug-in sockets. A step by step guide;

Setup Tuya local - refer details elsewhere.

  1. from the integration select configure

  2. add new device

  3. Select a discovered device

  4. Configure Tuya device

  5. Select entity type switch

  6. configure entity - ID 1, give it a name. leave the current, consumption and voltage fields blank

  7. next entity type selection. Select sensor, ensure ‘do not add any more entities’ is not checked.

  8. setup Power - ensure scaling factor is correct.

  9. repeat step 7.

  10. setup Voltage. Ensure scaling factor is correct.

  11. repeat step 7.

  12. Setup current

  13. finish adding entities by ticking ‘do not add any more entities’

  14. End result should be a switch control entity and three sensor entities.


Interesting. I also have defined entities for the voltage, current and power when adding the Arlec plug-in socket to see what differences between using entities or attributes.

I do notice a few differences with your screen shots though. In your steps 8, 10 and 12 your images show a “Scaling factor” field which I don’t have. In your step 14 you show a “Sensors” category, where all my entities are listed under the “Controls”.

Both approaches seem to record history, and are easy to work with. After problems with HA getting flooded by messages I have reduced the number of devices connected, removed some of the lovelace cards that may have been taking more CPU time, and gone back to adding sensor templates in configuration.yaml (as in the “Energy monitoring values” section of LocalTuya documentation ) to reduce the amount of network messages needing to be processed.

Ahh, right. I was defining the other entities as number and select types.

Current challenge is accumulating daily total for kWh.

1 Like

that … and that I have noticed that my 3 Arlec smart plugs regularly disconnect and immediately reconnect to my shiny new ASUS RT-AX55 wifi AP - despite being located 2m from the AP with line of sight; and other devices with worse rssi remaining online >200 hours.

But, the weird thing is that it happens regularly at 25 past the hour, most hours, and only affects the Grid connect devices (with up-to-date Tuya firmware).

I’m wondering if this arlec can be connected to Tuya?