Giter Club home page Giter Club logo

sense's People

Contributors

bdraco avatar benbogart avatar crkochan avatar dennypage avatar dsbecker avatar firestormo avatar flavio-fernandes avatar kbickar avatar kylekampy avatar lymanepp avatar michaeldavie avatar popre avatar scottbonline avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sense's Issues

Real-time Watt and DeviceID for active_devices

Started using your Library to create a interface between device ISY994i and the Sense API.

There two things that I would like to see and not sure if it already there and didn't see it or available on the Sense API. It would be to get the current watt usage of a device ? I see I can get the average but not the real-time value.

Also on the active device, do you know if you could also get the device id ? As name can change and would be difficult to link them back to the proper device id ?

get_trend_data method doesn't return anything

def get_trend_data(self, scale, dt=None):

I am not able to get any data from sense.get_trend_data('DAY') even after running sense.update_trend_data()

I am able to authenticate and have other device usage data returned such as sense.daily_usage

Apologies if this is just an error on my end - would appreciate any help.

Thanks!

Realtime device usage updates in HA

Has any consideration been given to using async_realtime_stream in the HA integration (without Single=True)? Having real-time push updates would make the data more useful (to me, anyways). It wouldn't have any more impact to Sense than leaving a browser tab open to the "Now" tab. Suppressing updates for a device when the data hasn't changed would limit the amount of data stored in HA.

daily_usage and daily_solar off by ~4 hours

I run this every minute to update current power, current solar, daily solar and daily usage.

I have noticed that my daily usage (and solar) max values get reported about 4 hours past midnight (I am located on the US east coast). Is this an issue with the API ? Or could the script be modified to accommodate for time zone ?

get_all_usage_data for time period

I need the on/off times for a specific device to compare runtime from now to a year ago. Getting the runtimes now is easy with get_all_usage_data() which returns DeviceOn and DeviceOff events.

Are there any options to get the on/off times for a device from a year ago?

The get_all_usage_data method passes a payload to the api. Currently the payload is hardcoded as:
payload = {'n_items': 30}

Is there a parameter that can be passed to the api to get usage data as of a time? I tried modifying the payload to:
payload = {'n_items': 20, 'start': '2020-10-30T16:24:35.314Z'} with no luck.

It's worth noting that the n_items parameter doesn't do anything. When modified to 20 or 1000 the api still returns 30 results.

Any ideas on how to get historical on/off data by device would be appreciated.

Websocket connection failure for realtime data

I can connect and see historical data, but invoking update_realtime() returns this error: ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1045)

Question: Disconnect logs?

Due to my power box being in a crawlspace, the wifi signal is weak, often disconnecting. I put in a support ticket with Sense and they show me some logs:

image

When I asked if this was available in some way (as there isn't a great way to see that info in the mobile or web app), they said:

Unfortunately, the disconnects logs are currently unavailable in the Sense app, however, that is not a suggestion we have had before so I have passed that along to our Product team as well as I think that would be a great feature addition in the future.

All of this is to say, are these logs available via the API? My main interest in using this is to more closely monitor the frequency and duration of these disconnects.

API works for an hour then fails

To troubleshoot I copied the code from the read me here and wrote this script:

from sense_energy import Senseable
import datetime
from time import sleep
sense = Senseable()
sense.authenticate('[email protected]', 'XXX')

def printmsg(msg) :                                        # Timestamped message
    print( " ", datetime.datetime.now().strftime( "%a %I:%M %p" ), msg )
    
while True:
    try:
        sense.update_realtime()
        sense.update_trend_data()
    except :
        printmsg("\033[31mSense Timeout\033[m")
        sleep(120)
        continue
    else :
        print ("Active:", sense.active_power, "W")
        print ("Active Solar:", sense.active_solar_power, "W")
        print ("Daily:", sense.daily_usage, "KWh")
        print ("Daily Solar:", sense.daily_production, "KWh")
        print ("Active Devices:",", ".join(sense.active_devices))
        printmsg('Wait three minutes...')
        sleep(180)

After one hour I get Sense Timeouts until I quit and relaunch the app, identical to how my original code is behaving.

I recently updated my Python but that shouldn't break the API

Can't run on python 2.7.6

/usr/local/lib/python2.7/dist-packages/urllib3/util/ssl_.py:354: SNIMissingWarning: An HTTPS request has been made, but the SNI (Server Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
SNIMissingWarning
/usr/local/lib/python2.7/dist-packages/urllib3/util/ssl_.py:150: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecurePlatformWarning
Traceback (most recent call last):
File "sense_api.py", line 246, in
print ("Active:", sense.active_power, "W")
File "sense_api.py", line 109, in active_power
if not self._realtime: self.get_realtime()
File "sense_api.py", line 77, in get_realtime
return next(self.get_realtime_stream())
File "sense_api.py", line 95, in get_realtime_stream
if ws: ws.close()
UnboundLocalError: local variable 'ws' referenced before assignment
root@TavChunk:~/src/sense-energy/sense_energy# python --version
Python 2.7.6

Timeouts - after 7pm every day??

Hi, I'm using the Sense Home Assistant integration, and I've noticed that every day at 7pm ET, my daily usage data goes to 0 and stay at 0 into the early mornings the next day before starting again. Link to image: https://ibb.co/wSWy6Lj

Today I used your wrapper to call the API directly, and this afternoon I was able to read my data, but this evening I'm getting timeouts from the API. Home Assistant likewise isn't getting updates, and I also can't access the Trends section in the Sense App.

So i guess the question is: are you aware of any rate-limiting in the Sense API?

I don't see other Sense-HA people with this same problem, so any idea why I'd have this rate limiting issue but not others?

Any help appreciated

Allows passing in websession

https://developers.home-assistant.io/docs/integration_quality_scale_index/#platinum-

from homeassistant.helpers.aiohttp_client import async_get_clientsession

It would be great if the client session could be passed in for the async version to minimize the object creation, reconnection, and executor jumps

2021-01-30 06:44:38 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 06:44:38 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 06:44:42 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 06:44:42 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 06:44:43 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('clientrt.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, 0), kwargs: {}
2021-01-30 06:44:43 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('clientrt.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, 0), kwargs: {}
2021-01-30 06:44:45 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 06:44:45 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 06:44:45 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 06:44:45 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 06:44:45 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 06:44:45 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 06:44:46 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 06:44:46 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 06:44:46 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 06:44:46 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 06:45:45 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('clientrt.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, 0), kwargs: {}
2021-01-30 06:45:45 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('clientrt.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, 0), kwargs: {}
2021-01-30 06:47:45 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('clientrt.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, 0), kwargs: {}
2021-01-30 06:47:45 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('clientrt.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, 0), kwargs: {}
2021-01-30 06:49:45 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('clientrt.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, 0), kwargs: {}
2021-01-30 06:49:45 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('clientrt.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, 0), kwargs: {}
2021-01-30 06:49:46 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 06:49:46 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 06:49:46 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 06:49:46 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 06:49:46 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 06:49:46 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 06:49:46 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 06:49:47 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 06:49:47 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 06:49:47 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 06:51:45 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('clientrt.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, 0), kwargs: {}
2021-01-30 06:51:45 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('clientrt.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, 0), kwargs: {}
2021-01-30 06:53:45 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('clientrt.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, 0), kwargs: {}
2021-01-30 06:53:45 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('clientrt.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, 0), kwargs: {}
2021-01-30 06:54:47 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 06:54:47 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 06:54:47 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 06:54:47 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 06:54:47 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 06:54:47 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 06:54:48 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 06:54:48 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 06:54:48 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 06:54:48 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 06:55:45 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('clientrt.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, 0), kwargs: {}
2021-01-30 06:55:45 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('clientrt.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, 0), kwargs: {}
2021-01-30 06:57:45 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('clientrt.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, 0), kwargs: {}
2021-01-30 06:57:45 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('clientrt.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, 0), kwargs: {}
2021-01-30 06:59:45 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('clientrt.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, 0), kwargs: {}
2021-01-30 06:59:45 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('clientrt.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, 0), kwargs: {}
2021-01-30 06:59:48 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 06:59:48 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 06:59:48 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 06:59:48 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 06:59:48 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 06:59:48 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 06:59:48 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 06:59:48 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 06:59:49 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 06:59:49 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 07:01:45 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('clientrt.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, 0), kwargs: {}
2021-01-30 07:01:45 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('clientrt.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, 0), kwargs: {}
2021-01-30 07:03:45 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('clientrt.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, 0), kwargs: {}
2021-01-30 07:03:45 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('clientrt.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, 0), kwargs: {}
2021-01-30 07:04:49 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 07:04:49 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 07:04:49 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 07:04:49 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 07:04:49 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 07:04:49 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 07:04:49 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 07:04:49 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 07:04:50 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}
2021-01-30 07:04:50 DEBUG (MainThread) [homeassistant.runner] Calling executor with function: <function getaddrinfo at 0x7ff7de3ed3a0>, args: ('api.sense.com', 443, 0, <SocketKind.SOCK_STREAM: 1>, 0, <AddressInfo.AI_ADDRCONFIG: 32>), kwargs: {}

pip install sense_energy fails because it can't find README.md

When I try to install using 'sudo pip install sense_energy -v -v -v' I get the error below. Not sure why it is complaining about README.md since that seems to exist. Any ideas?

Added sense_energy from https://files.pythonhosted.org/packages/31/af/93c297b301f7daffea733708528c00048ef72fa544ca1457148331662185/sense_energy-0.4.1.tar.gz#sha256=00091d9f81a70135810635951c2fbd594e3ff247786726778a218448f7569577 to build tracker '/tmp/pip-req-tracker-MO4tPB'
Running setup.py (path:/tmp/pip-install-D2SLlB/sense-energy/setup.py) egg_info for package sense-energy
Running command python setup.py egg_info
Traceback (most recent call last):
File "", line 1, in
File "/tmp/pip-install-D2SLlB/sense-energy/setup.py", line 3, in
with open("README.md", "r") as fh:
IOError: [Errno 2] No such file or directory: 'README.md'
Cleaning up...
Removing source in /tmp/pip-install-D2SLlB/sense-energy
Removed sense_energy from https://files.pythonhosted.org/packages/31/af/93c297b301f7daffea733708528c00048ef72fa544ca1457148331662185/sense_energy-0.4.1.tar.gz#sha256=00091d9f81a70135810635951c2fbd594e3ff247786726778a218448f7569577 from build tracker '/tmp/pip-req-tracker-MO4tPB'
Removed build tracker '/tmp/pip-req-tracker-MO4tPB'
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-D2SLlB/sense-energy/

Repeat print every 5 seconds

This is an awesome script - thanks!

I want to feed this information into a file so that Splunk can play with it. How do I get active devices to display every 5 seconds?

For example:
('Active Devices:', u'Other, Always On')
('Active Devices:', u'Other, Fridge, Always On')
('Active Devices:', u'Other, Fridge, Always On')
('Active Devices:', u'Other, Oven, Always On')
('Active Devices:', u'Other, Kettle, Always On')

Leg1 Leg2 Data for 400amp Split Systems - Wattage reading incorrect

Hi - I am not sure if this is the right place to leave this but I am having an issue with the API. My whole purpose to getting the Sense device was to use the second port to 'meter' a second 200amp connection (both in my one big box). I have confirmed with the Sense team normally the legs are measured as the following:

Leg1 = MainClamp1 + AuxClamp1
Leg2 = MainClamp2 + AuxClamp2

So I re-wired my clamps by swapping them so that I read:
Leg1 = MainLead1 + MainLead2
Leg2 = AuxLead1 + AuxLead2

The easiest way I did this was watching the sense webapp to show me wattage usage per leg, made quick work of it. Then I pull the data down with a python script (from API) and log Leg1/Leg2 wattage into a MySQL Database, which powers a Grafana Graph. My main area of concern is:

The data returned by the API is no longer indicative of that in the webapp for [ Leg1W , Leg2W ] , [ ... ] and still shows very similar numbers in relation to each other as they did before... Here is an example which was too recent to show all the data (i expected this outcome of 1 -1 but not the numbers). My Leg2 has been under 1000 watts through this entire time but the data does not show this:

{"totals":[[2151,2151],[2150,2151],[2151,2165],[2165,2166],[2166,2167],[2163,2166],[2161,2163],[2163,2176],[2170,2170],[2166,2170],[2163,2166],[2163,2163],[2160,2163],[2163,2168],[2168,2168],[2168,2168],[2160,2168],[2163,2163],[2163,2168],[2163,2163],[2163,2166],[2160,2163],[2158,2160],[2160,2160],[2160,2164],[2164,2186],[2171,2171],[2154,2171],[2166,2166],[2160,2166],[2162,2162],[2159,2162],[2151,2159],[2151,2151],[2151,2159],[2159,2159],[2150,2159],[2150,2150],[2150,2154],[2154,2156],[2150,2154],[2146,2150],[2145,2146],[2146,2160],[2147,2147],[2147,2149],[2149,2154],[2146,2149],[2149,2149],[2149,2161],[2161,2165],[2162,2162],[2160,2162],[2151,2160],[2154,2154],[2154,2165],[2160,2160],[2155,2160],[2151,2155],[2152,2152],[2151,2152],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1],[1,-1]],"endOfData":"2021-05-10T14:34:10.000Z","start":"2021-05-10T14:33:10.000Z"}

I did factory reset the sense device when swapping the Leads as I did... Not sure what else may be wrong.

Thanks in advance for any help.

Colton Riffel

creating ssl context does blocking I/O

2023-09-06 12:43:39.362 WARNING (MainThread) [homeassistant.util.async_] Detected blocking call to load_default_certs inside the event loop. This is causing stability issues. Please report issue for sense doing blocking calls at homeassistant/components/sense/init.py, line 74: gateway = ASyncSenseable(

aiohttp works around this with an lru

Tag and submit to pypi

tag the sense API so it can be put on pypi?

git tag 0.1 -m "first release"
git push --tags origin master

I can submit it then or if you want to, follow the instructions on http://peterdowns.com/posts/first-time-with-pypi.html if you want to submit it, here's a setup.py file:

from distutils.core import setup
setup(
  name = 'sense-energy',
  packages = ['sense-energy'], 
  install_requires=[
      'requests',
      'websocket-client',
  ],
  version = '0.1',
  description = 'API for the Sense Energy Monitor',
  author = 'scottbonline',
  author_email = '[email protected]?',
  url = 'https://github.com/scottbonline/sense',
  download_url = 'https://github.com/scottbonline/sense/archive/0.1.tar.gz', 
  keywords = ['sense', 'energy', 'api'], 
  classifiers = [],
)

JSONDecodeError After One Hour

I updated my code to use the new request_token but now I'm having an issue where, one hour after I do a .authenticate() and get an access token, I start getting JSONDecodeErrors and have to generate a new session and access_token.

Traceback (most recent call last):
File "/root/wallclock/venv/lib/python3.8/site-packages/flask/app.py", line 2525, in wsgi_app
response = self.full_dispatch_request()
File "/root/wallclock/venv/lib/python3.8/site-packages/flask/app.py", line 1822, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/root/wallclock/venv/lib/python3.8/site-packages/flask/app.py", line 1820, in full_dispatch_request
rv = self.dispatch_request()
File "/root/wallclock/venv/lib/python3.8/site-packages/flask/app.py", line 1796, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
File "/root/wallclock/weather.py", line 78, in get_weather
sense.update_realtime()
File "/root/wallclock/venv/lib/python3.8/site-packages/sense_energy/senseable.py", line 135, in update_realtime
next(self.get_realtime_stream())
File "/root/wallclock/venv/lib/python3.8/site-packages/sense_energy/senseable.py", line 145, in get_realtime_stream
result = json.loads(ws.recv())
File "/usr/lib/python3.8/json/init.py", line 357, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Even if I'm calling it frequently, the next attempt one hour after the access_token was generated I start getting these errors. If I try to call the renew_auth method, I get a credential error message.

Slamming Sense's internal API with authentication requests

https://community.sense.com/t/download-or-api-to-feed-pvoutput/3033/25

RyanAtSense
Community Manager

Hey guys. It’s come to the engineering team’s attention that the unofficial APIs posted are slamming our internal API with authentication requests pretty much constantly. This is causing some performance degradation on our end. We have no issue with these APIs existing and being utilized by our userbase, but they should not be coded in such a way as to negatively affect performance for our teams and the rest of our users. We’ve contacted the owners of both Github repositories so they can make the necessary changes to their code.

Timeouts

Please add timeouts to all requests. Otherwise the session stays open till the server reaches its timeout which can take a while.

The Integration for Home Assistant uses an interval of 10 seconds.

MQTT support

Any chance of using paho-mqtt to allow sense-energy to publish topics to a MQTT broker? This would allow integration with several smart home controllers such as HomeSeer and Hubitat. I can take a crack at it in a fork, but I will have to learn Python as I go.

Error appearing with new websocket version

I upgraded to the newest version of websocket (released this month) and the sense_api now throws an error:

from sense_api import Senseable
File "/home/user/sense/sense_energy/sense_api.py", line 5, in <module>
 from websocket import create_connection
ImportError: cannot import name create_connection

Calling get_realtime() doesn't seem to update data without re-authentication

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('[email protected]', '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)

ModuleNotFoundError: No module named '__main__.sense_exceptions'; '__main__' is not a package

I'm relatively new to Python. I've only written a small py to read temp from a sensor I built on a Raspberry Pi.

I want to explore your Sense API because it looks promising. I am running into this issue.

Traceback (most recent call last):
  File "sense_api.py", line 8, in <module>
    from .sense_exceptions import *
ModuleNotFoundError: No module named '__main__.sense_exceptions'; '__main__' is not a package

I am confident this is nothing to do with the code, but my environment setup and config. I wanted to document as an issue here for any behind me to find assistance if experiencing the same issue.

I'm running Windows 10, Python 3.7.2 and pip 19.0.2.

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.