Basic plug automation setup help

Hi there, I’m a beginner to home automation. I’d like to know your opinion on how it would be possible to take an API response and use those values to enable or disable a Wi-Fi plug.

The plug I’m intending to use this plug which supports Google Assistant and Amazon assistant and according to reviews Home Assistant works as well.

I’m not sure if it would be possible to accomplish with that plug so if not could you recommend something better for this use case.

Here are the values returned by the API request:
“code”: “0”,
“message”: “Success”,
“data”: {
“soc”: 83,
“remainTime”: -5939,
“wattsOutSum”: 74,
“wattsInSum”: 83

And here is the logic that would need to be applied in the task:
if “message” value is “Success” then apply the below
if “wattsInSum” value is below 350 and “soc” value is below 50
then activate plug power and keep activated until “soc” value is 95 then deactivate plug power
or
if “wattsInsum” value reaches 350 or above in which case, deactivate plug power

if “message” value is “Fail” then apply the below
Do nothing

I think this is a Tuya device. The (very complicated!) integration docs are here:

There’s also a HACS integration called Local Tuya, which supports Tuya IoT Cloud APIs