Riebart / vivint.py

Python object model interface for the Vivint cloud API.
Mozilla Public License 2.0
31 stars 11 forks source link

alarm status is not updated or i'm doing something wrong #5

Closed 7ooL closed 4 years ago

7ooL commented 5 years ago

I'm getting my feet wet with your api script and i can't seem to get the status of alarm to update between polling.

` log("Establishing session", verbose) session = vivint.VivintCloudSession(username,password) log("Listing panels", verbose) panels = session.get_panels()

while running:

    for panel in panels:
        __log("Updating panel %d" % panel.id(), verbose)
        panel.update_devices()

        __log("Panel arm state: %s" % panel.get_armed_state(), verbose)

    __log("Sleeping", verbose)
    time.sleep(interval)

`

despite changing the alarm status on my phone it stays the same each poll. if i restart the script the updated status is shown. I;m under the impression that update_devices() should pull the new states.

7ooL commented 5 years ago

any thoughts on this?

Riebart commented 4 years ago

So, shame on me for letting this languish, you were absolutely right.

Fixed now in https://github.com/Riebart/vivint.py/commit/9fdc59509d7c2d351819ae0935b423c5f7180020 , so the following works as expected:

>>> import os, json, vivint
>>> session = vivint.VivintCloudSession(os.environ["USERNAME"], os.environ["PASSWORD"]); panels = session.get_panels();
p = panels[0]
>>> p.get_armed_state()
'disarmed'
>>> p.update_devices()
>>> p.get_armed_state()
'armed_stay'
>>> p.update_devices()
>>> p.get_armed_state()
'disarmed'
>>>

It also supports arming and disarming with PanelRoot.set_armed_state() using either strings, or integer armed state IDs.