Calling get_realtime() doesn't seem to update data without re-authentication
addohm opened this issue · 0 comments
addohm commented
In some abbreviated testing of this package, I'm finding that the get_realtime() function doesn't actually update the data without re-authentication, regardless of how often I call it.
modified sense_api.py
import json
import sys
from time import time
from datetime import datetime
from .sense_exceptions import *
API_URL = 'https://api.sense.com/apiservice/api/v1/'
WS_URL = "wss://clientrt.sense.com/monitors/%s/realtimefeed?access_token=%s"
API_TIMEOUT = 5
WSS_TIMEOUT = 5
RATE_LIMIT = 60
# for the last hour, day, week, month, or year
valid_scales = ['HOUR', 'DAY', 'WEEK', 'MONTH', 'YEAR']
class SenseableBase(object):
def __init__(self, username=None, password=None,
api_timeout=API_TIMEOUT, wss_timeout=WSS_TIMEOUT, rate_limit=RATE_LIMIT):
# Timeout instance variables
self.api_timeout = api_timeout
self.wss_timeout = wss_timeout
self.rate_limit = rate_limit
...
test_script.py
import time
from sense_energy import Senseable
REFRESH_RATE = 30
if __name__ == '__main__':
sense = Senseable(rate_limit=REFRESH_RATE)
sense.authenticate('addohm@gmail.com', 'Bms#22540')
while True:
sense.update_realtime()
print ("Real time consumption:", sense.active_power, "W")
print ("Real time production:", sense.active_solar_power, "W")
time.sleep(REFRESH_RATE)