Get Tapo P110 power consumption

Hey SharpTools community!

I bought my first smart sensors last week.
It started by wanting to monitor temperatures and power consumption in an effort to save some energy. So for now I have a few temp & humidity sensors, a few smart plugs (and camera to monitor our dog while away but that’s unrelated)

I’ve been digging into various platforms and integrations and for now it seems that SharpTools seems to be what works best for me.
I love how I can create more complex automations compared to the Tapo or SmartThings apps (and I’m not as experienced in coding yet to create my own SmartThings scripts)

So thanks for creating this great tool <3
I’ll probably get the premium account since I’m already getting used to custom and super tiles plus I need the variables for some of my automations!

On to my issue where I need help:

  • I got some Tapo P110 plugs to monitor power consumption but they don’t seem to show consumption on the tiles. I can only get the switch status.

  • I found that other people have the same issue in smartthings so followed the instructions and found out that the power consumption is reported as an object like this

{"start":"2024-07-25T15:46:22.201Z","end":"2024-07-25T16:01:22.201Z","energy":15,"deltaEnergy":4}

I imagine for the tiles to show it, it would need to be just a value and not JSON formatted.

  • I created a rule that would trigger on a random event to see what info SharpTools gets from the plug and sure enough it gets this

So here are my questions:

  1. Is there a way to get this info into a custom or super tile?

  2. Is there a way to get this info (probably by inserting it into a variable?) and use it as a trigger for automations?
    One of the things I want to do is create an automation where, if the plug is consuming less than a certain amount of energy , the plug switches off (to eliminate energy consumption by devices that still consume some watts while off)

I’d appreciate some help with these as I have some grasp of coding but the bear minimum! Thanks

I would try setting up a rule that is triggered when the powerConsumption attribute changes and then try writing the value.energy to a variable using an expression.

  1. Action → Set Variable
  2. Pick your variable to write to (create one first)
  3. Select Expression as the Source
  4. Use an expression like:
    $context.event.value.energy
    

Once you have the energy value in a variable, you can display it in a tile or use it in rules however you see fit.

Thanks for the reply @josh
Unfortunately it doesn’t work.

  • I created the variable (tried with both types: text and Num)

  • Created a rule that triggers on powerConsumption update and saves $context.event.value.energy

  • The variable remained empty

I then tried saving the $context.event.value and I managed to get this into the variable
image

Now, is there a way to get the individual “energy” value from this to another variable?

I tried adding this in a new rule to test it out: parseJson($PowerFridge)
But the evaluation fails with Evaluation error: Unexpected end of JSON input

UPDATE
Hmm… Don’t know if I changed something, but now the evaluation seems to work.
I’ll keep working on it and post any updates issues I might encounter

1 Like