We'd like to remind Forumites to please avoid political debate on the Forum... Read More »
We're aware that some users are experiencing technical issues which the team are working to resolve. See the Community Noticeboard for more info. Thank you for your patience.
📨 Have you signed up to the Forum's new Email Digest yet? Get a selection of trending threads sent straight to your inbox daily, weekly or monthly!
Tapo p110 Switched on and off every 5 Minutes?
Options
Comments
-
GDB2222 said:You could just try out ChatGPT's code and see whether it works. No guarantees, of course, but it's unlikely to cause a major calamity.There is no attribute for getState().
current_state = p110.getState() # Check if the plug is on or offAttributeError: 'P110' object has no attribute 'getState'0 -
Since your main issue was to prevent the multiple repetitions of an On command when it was already ON ( or visa versa)
You can set up a variable in your code to record the 'state' of the plug as you see it,
where the state reflects what you last set it to and use that the prevent issuing further On commands if already On
Something like this, pseudo code
Int state = false
const OFF = 1
const ON = 2
Loop
If temp < 20 and state != ON then
turn on heater
state = ON
if temp > 20 and state != OFF then
turn off heater
state = OFF0 -
bob_a_builder said:Since your main issue was to prevent the multiple repetitions of an On command when it was already ON ( or visa versa)
You can set up a variable in your code to record the 'state' of the plug as you see it,
where the state reflects what you last set it to and use that the prevent issuing further On commands if already On
Something like this, pseudo code
Int state = false
const OFF = 1
const ON = 2
Loop
If temp < 20 and state != ON then
turn on heater
state = ON
if temp > 20 and state != OFF then
turn off heater
state = OFF0
Confirm your email address to Create Threads and Reply

Categories
- All Categories
- 351K Banking & Borrowing
- 253.1K Reduce Debt & Boost Income
- 453.6K Spending & Discounts
- 244K Work, Benefits & Business
- 599K Mortgages, Homes & Bills
- 176.9K Life & Family
- 257.4K Travel & Transport
- 1.5M Hobbies & Leisure
- 16.1K Discuss & Feedback
- 37.6K Read-Only Boards