Skip to content
This repository was archived by the owner on Sep 4, 2021. It is now read-only.
This repository was archived by the owner on Sep 4, 2021. It is now read-only.

Repeated use of status() turns off light #29

@law1964

Description

@law1964

The light connected to my device starts in the ON (True) state.. I run the following python script:

import pytuya, time

old_state=[False, False, False]
SmartLife=["", "", ""]
SmartLife[1] = pytuya.OutletDevice('02200270ecfabc8e2ff0', '192.168.20.39', 'ceb9acd336c853f2')
SmartLife[2] = pytuya.OutletDevice('04200086b4e62d121b87', '192.168.20.14', '3e637e09ea909522') #Desk Lamp

device_set={2}
for i in device_set:
    data = SmartLife[i].status()
    old_state[i] = data['dps']['1']
    print ("*** Polling started " + time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime())
        + " " + str(i) + " " + str(old_state[i]) )

while True:
    for i in device_set:
        data = SmartLife[i].status()
        state = data['dps']['1']
        if (state != old_state[i]):
            print time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime()) + " State has changed to " + str(i) + " " + str(state)
            old_state[i]=state
        time.sleep(0.5)

The resulting console output:

*** Polling started Thu, 28 Jun 2018 10:18:46 2 True
Thu, 28 Jun 2018 10:48:33 State has changed to 2 False

There are no timers on the device. Nor is there user intervention. The light turns off by itself. This is repeatable (and an eventuality) on multiple but not all devices.

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions