Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

power plug turn off and back on for no reason #152

Closed
rdeangel opened this issue Nov 11, 2020 · 15 comments
Closed

power plug turn off and back on for no reason #152

rdeangel opened this issue Nov 11, 2020 · 15 comments
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@rdeangel
Copy link

I noticed that when monitoring a power plug with flactuating energy reading which constantly change the power plug occasionally turns off and immediately powers back on.
This stops when I remove it from localtuya.

I also have to use both localtuya and the regular tuya integration in order to power on and off the plug. I don't seem to be able to change the on and off status with localtuya alone.

@rdeangel
Copy link
Author

rdeangel commented Nov 12, 2020

ok the issue I described above was actually user error. One of my automations was unnecessarily turning the plug off when it was already off causing the state of the sensor to flicker. I fixed that by putting a condition before the action in the automation.

What is annoying though is that the transitioning between states has always the intermediate state "unavailable". This causes issue with automations when the defined conditions include "on" to "off" transitions and viceversa for example.

@postlund
Copy link
Collaborator

You should not see any unavailable state changes unless there's any issue of some sort. Do you have any errors in the log?

@postlund postlund added bug Something isn't working question Further information is requested labels Nov 15, 2020
@rdeangel
Copy link
Author

Hi Thanks for looking into this.

the below is what I'm referring to visually in home assistant:
localtuya

and this is what I can see in the logs:
image

@postlund
Copy link
Collaborator

@rdeangel That looks really strange, but at least there are a few errors. Can you post the error log?

@rdeangel
Copy link
Author

see logs here: localtuya_logs.txt

@postlund
Copy link
Collaborator

Are you using the tuya integration as well? You have to disable that. Looks like one of the devices always fail to decide the incoming payload. Did you configure via YAML or config flow? If YAML, how does the config look like?

@rdeangel
Copy link
Author

rdeangel commented Nov 16, 2020

Initially I deleted the tuya integration and tried to get everything to work with localtuya but I was not succesfull.

I use the tuya integration along with localtuya because I couldn't get localtuya to change the state of the plug (on and off), I can only successfully read the energy readings with localtuya (except for the issue mentioned).

Also because Tuya is unable to read the plug status in realtime when switched via the plug button I use the localtuya state changes (on and off) to update the tuya integration switch object.
I know it's messy and probably the rootcause of the issue but it's the only way I could get it to fully work (except for the errors/unavailable intermittent issue)

I assumed localtuya was unable to change the state of my plug (I thought it was odd, but I'm guessing based on what you said that it should work fine)

I configured it manually with yaml and tried both styles of config, switch and sensor based, both had issues.

local_tuya.txt

@postlund
Copy link
Collaborator

Ok, so I'm not really sure where we are right now. Based on the log earlier, I got the feeling that you had multiple power plugs, was that the case? It would be great if you could test according to this:

  1. Remove both the tuya and localtuya integrations so you are on a clean slate
  2. Add one power plug to localtuya
  3. Use the config from your previous post, but use the switch instead of binary_sensor
  4. Verify if you can turn on/off the plug from Home Assistant
  5. Verify if state is reflected in Home Assistant when you press the physical button on the plug
  6. Keep monitoring the debug log (attach it here if it doesn't work as expected)

@rdeangel
Copy link
Author

rdeangel commented Nov 17, 2020

I'm afraid it just won't work, I'm using "switch" instead of "binary_sensor" and while I can monitor the plug, I can't interact with it without tuya.

See file attached (I tried to soft switch from off to on (twice) from the switch.localtuya object but the soft button just goes back to off after a couple of seconds and I get the error "Failed to set DP 1 to 1" at the same time)
local_tuya_logs_no_state_change.txt
In the logs you'll also see messages related to me physically switching the plug from off to on (again twice), when I do this the switch on home assistant passively detects on and off appropriately.

@postlund
Copy link
Collaborator

I get the feeling that something isn't quite working with the encryption. Would it be possible for me to get access to the plug somehow so I can try some things out? It would be a lot easier than trying to pass commits bank and forth.

@rdeangel
Copy link
Author

rdeangel commented Nov 17, 2020

"Would it be possible for me to get access to the plug somehow" how do you suggest?

these are the plugs btw:
https://www.amazon.co.uk/Slitinto-Monitoring-Control-Function-Required/dp/B07DVXNNH4/

@postlund
Copy link
Collaborator

Preferably if we could set up a tunnel of some sort or if you could hook it up to a virtual machine I can access. I would need some way to run python code and connect to it.

@rdeangel
Copy link
Author

Sure I can create an ubuntu vm and a wifi on an isolated vlan and give you access to do your tests via zerotier.

Does that work?

@postlund
Copy link
Collaborator

Sounds perfect 👌

@postlund postlund self-assigned this Nov 17, 2020
@rdeangel
Copy link
Author

rdeangel commented Nov 20, 2020

All working now.

This was not a bug rather just the plain and old user error, for not having set the correct key.

Watch out by the way, when you reassociate the plug or device with the smart app your local_key changes, so you need to go and check what it is again.

Thanks @postlund for your help, I hate to waste someone's time, but that's just what I did in this occasion.

PaulCavill pushed a commit to PaulCavill/localtuya that referenced this issue May 9, 2024
SKULSHADY pushed a commit to SKULSHADY/localtuya that referenced this issue Dec 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants