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

More metadata about battery and communication status #106

Closed
technicalpickles opened this issue Dec 25, 2018 · 1 comment
Closed

More metadata about battery and communication status #106

technicalpickles opened this issue Dec 25, 2018 · 1 comment

Comments

@technicalpickles
Copy link

I have like 6 Schlage Connects, and 3 of them are in various states of flakiness. When I look at HomeAssistant, there isn't really anything to indicate that there are problems iwth them, except for 1 that has 0% battery.

It'd be super useful to have additional metadata. I started poking around a VeraDoor object to see what kinda of data the API already has. A few fields seem relevant:

  • BatteryDate: seconds since epoch... for hte last time the battery changed?
  • CommFailure: seems to be 0 or 1
  • CommFailureDate: seconds since epoch since CommFailure?
  • PollOk: no idea, but it's an integer
  • LastPollSuccess: no idea what it considers a success, since most of the ones I'm seeing are pretty far back

Here's a snippet I'm playing with, based on the list-devices:

import sys
import time
import os
import IPython
from IPython import embed

# Import pyvera
import pyvera

# Parse Arguments
import argparse
parser = argparse.ArgumentParser(description='list-devices')
parser.add_argument('-u', '--url', help="Vera URL, e.g. http://192.168.1.161:3480", required=True)
args = parser.parse_args()

# Start the controller
controller, _ = pyvera.init_controller(args.url)

try:
    # Get a list of all the devices on the vera controller
    all_devices = controller.get_devices()

    # Print the devices out
    for device in all_devices:
        if type(device).__name__ == "VeraLock":
            #  embed()

            print('{} ({})'.format(device.name, device.device_id))
            poll_ok = device.get_complex_value('PollOk')
            if poll_ok is not None:
                print('PollOk: {}'.format(poll_ok))
                last_poll_success = device.get_complex_value('LastPollSuccess')
                if last_poll_success is not None:
                    print('LastPollSuccess: {}'.format(time.ctime(int(last_poll_success))))
            print('BatteryLevel: {}%'.format(device.battery_level))
            print('BatteryDate: {}'.format(time.ctime(int(device.get_complex_value('BatteryDate')))))
            comm_failure = device.get_strict_value('commFailure')
            print('CommFailure: {}'.format(comm_failure))
            if comm_failure != '0':
                print('CommFailureDate: {}'.format(time.ctime(int(device.get_complex_value('CommFailureTime')))))
            print('Status: {}'.format(device.get_value('status')))
            print()

finally:
    # Stop the subscription listening thread so we can quit
    controller.stop()
@pavoni
Copy link
Collaborator

pavoni commented Jun 3, 2019

Sorry for the long delay - would welcome a PR to add something to the examples directory if you'd like to do this.

Closing the issue for now.

@pavoni pavoni closed this as completed Jun 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants