jertel / vuegraf

Populate metrics from your Emporia Vue energy monitoring devices into an InfluxDB
MIT License
169 stars 54 forks source link

Detailed Data Issue #63

Closed tgregory86 closed 3 years ago

tgregory86 commented 3 years ago

First off, thanks for creating this great project. I am running the latest version 1.3.2 and noticed in my logs, that when it tries to pull the detailed data every hour, it gets the following error every time:

today at 6:42:55 AM 2021-08-25 10:42:55.292851 | ERROR | Failed to record new usage data: (<class 'TypeError'>, TypeError("unsupported operand type(s) for : 'float' and 'NoneType'"), <traceback object at 0x7f8bfe5eecc0>) today at 6:42:55 AM Traceback (most recent call last): today at 6:42:55 AM File "/opt/vuegraf/vuegraf.py", line 219, in today at 6:42:55 AM extractDataPoints(device, usageDataPoints) today at 6:42:55 AM File "/opt/vuegraf/vuegraf.py", line 133, in extractDataPoints today at 6:42:55 AM watts = float(secondsInAMinute minutesInAnHour wattsInAKw) kwhUsage today at 6:42:55 AM TypeError: unsupported operand type(s) for *: 'float' and 'NoneType'

jertel commented 3 years ago

I pushed a change to resolve this. Let me know if it works better.

tgregory86 commented 3 years ago

So far its working. Was the 1,2,3 channel name renamed to exclude the 1,2,3 in a recent update?

jertel commented 3 years ago

Not that I know of. Mine still shows a "1,2,3" channel number, if that's what you're referring to. The channel name has always matched the name that is entered into the Emporia mobile app.

tgregory86 commented 3 years ago

I have 2 VUE in my account it looks like the detailed info is only being pulled for one of them not the other:

image

Also you can see the Right1,2,3 is gone, now its just reported as "Right"

energy_usage,account_name=Home,detailed=False,device_name=Home-Left-1,host=telegraf_vue usage=0 1629901269039036000 energy_usage,account_name=Home,detailed=False,device_name=Home-Left-2,host=telegraf_vue usage=0 1629901269039036000 energy_usage,account_name=Home,detailed=False,device_name=Home-Left-3,host=telegraf_vue usage=0 1629901269039036000 energy_usage,account_name=Home,detailed=False,device_name=Home-Left-4,host=telegraf_vue usage=0 1629901269039036000 energy_usage,account_name=Home,detailed=False,device_name=Home-Left-5,host=telegraf_vue usage=0 1629901269039036000 energy_usage,account_name=Home,detailed=False,device_name=Home-Left-6,host=telegraf_vue usage=0 1629901269039036000 energy_usage,account_name=Home,detailed=False,device_name=Home-Left-7,host=telegraf_vue usage=0.10997020403544108 1629901269039036000 energy_usage,account_name=Home,detailed=False,device_name=Home-Left-8,host=telegraf_vue usage=0 1629901269039036000 energy_usage,account_name=Home,detailed=False,device_name=Home-Left-9,host=telegraf_vue usage=0.9028270562489827 1629901269039036000 energy_usage,account_name=Home,detailed=False,device_name=Home-Left-10,host=telegraf_vue usage=0 1629901269039036000 energy_usage,account_name=Home,detailed=False,device_name=Home-Left-11,host=telegraf_vue usage=0 1629901269039036000 energy_usage,account_name=Home,detailed=False,device_name=Home-Left-12,host=telegraf_vue usage=7.622413738568625 1629901269039036000 energy_usage,account_name=Home,detailed=False,device_name=Home-Left-13,host=telegraf_vue usage=113.55591757297516 1629901269039036000 energy_usage,account_name=Home,detailed=False,device_name=Home-Left-15,host=telegraf_vue usage=108.519766998291 1629901269039036000 energy_usage,account_name=Home,detailed=False,device_name=Home-Left-Balance,host=telegraf_vue usage=-230.71089557011922 1629901269039036000 energy_usage,account_name=Home,detailed=False,device_name=Home-Right,host=telegraf_vue usage=1107.3341161092121 1629901329255249000 energy_usage,account_name=Home,detailed=False,device_name=Home-Right-1,host=telegraf_vue usage=60.80668983459472 1629901329255249000 energy_usage,account_name=Home,detailed=False,device_name=Home-Right-2,host=telegraf_vue usage=0 1629901329255249000 energy_usage,account_name=Home,detailed=False,device_name=Home-Right-3,host=telegraf_vue usage=0 1629901329255249000 energy_usage,account_name=Home,detailed=False,device_name=Home-Right-4,host=telegraf_vue usage=313.795746866862 1629901329255249000 energy_usage,account_name=Home,detailed=False,device_name=Home-Right-5,host=telegraf_vue usage=64.13424002329508 1629901329255249000 energy_usage,account_name=Home,detailed=False,device_name=Home-Right-6,host=telegraf_vue usage=68.4235819498698 1629901329255249000 energy_usage,account_name=Home,detailed=False,device_name=Home-Right-7,host=telegraf_vue usage=90.26313540140788 1629901329255249000 energy_usage,account_name=Home,detailed=False,device_name=Home-Right-8,host=telegraf_vue usage=342.6018732706705 1629901329255249000 energy_usage,account_name=Home,detailed=False,device_name=Home-Right-9,host=telegraf_vue usage=0 1629901329255249000 energy_usage,account_name=Home,detailed=False,device_name=Home-Right-10,host=telegraf_vue usage=7.565475654602051 1629901329255249000 energy_usage,account_name=Home,detailed=False,device_name=Home-Right-11,host=telegraf_vue usage=14.98960475921631 1629901329255249000 energy_usage,account_name=Home,detailed=False,device_name=Home-Right-12,host=telegraf_vue usage=0 1629901329255249000 energy_usage,account_name=Home,detailed=False,device_name=Home-Right-13,host=telegraf_vue usage=112.76012763977052 1629901329255249000 energy_usage,account_name=Home,detailed=False,device_name=Home-Right-14,host=telegraf_vue usage=0 1629901329255249000 energy_usage,account_name=Home,detailed=False,device_name=Home-Right-Balance,host=telegraf_vue usage=31.99364070892337 1629901329255249000

That changed after the latest update I pulled, previously it was Right1,2,3

jertel commented 3 years ago

I'm not sure what caused your channel number to be concatenated to your channel name like that, especially without a hyphen. I checked back 2 weeks ago and my influxDB does not have 1,2,3 appended to my main:

> select * from energy_usage where device_name =~ /Right/ and  time > now()-14d and detailed='False'
name: energy_usage
time                        account_name detailed device_name         usage
----                        ------------ -------- -----------         -----
2021-08-11T14:46:36.653261Z Jason Ertel  False    Right Panel         606.0146715164185
2021-08-11T14:47:36.803002Z Jason Ertel  False    Right Panel         601.2132813135784

The lookupChannelName() method was refactored in the latest release, and that's where the appending occurs, but I cannot see how the pre-refactor version would have led the a channel name like "Right1,2,3".

As far as the detail data only pulled for one, that again I don't see in my local environment. Both Left and Right panels are showing detailed data. Are your devices nested into each other? It shouldn't matter but just trying to think of something that might be different from my setup.

tgregory86 commented 3 years ago

They are not nested.

tgregory86 commented 3 years ago

I am not sure if this is the cause or not, but i see in the logs its throwing an error every hour when it tries to pull the detailed data:

today at 11:27:46 AM 2021-08-25 15:27:46.096746 | INFO  | Submitting datapoints to database; account="Home"; points=104779
today at 11:28:22 AM 2021-08-25 15:28:22.826134 | ERROR | Failed to record new usage data: (<class 'requests.exceptions.ConnectionError'>, ConnectionError(ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))), <traceback object at 0x7f1f38adfa80>)
today at 11:28:22 AM Traceback (most recent call last):
today at 11:28:22 AM   File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 699, in urlopen
today at 11:28:22 AM     httplib_response = self._make_request(
today at 11:28:22 AM   File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 445, in _make_request
today at 11:28:22 AM     six.raise_from(e, None)
today at 11:28:22 AM   File "<string>", line 3, in raise_from
today at 11:28:22 AM   File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 440, in _make_request
today at 11:28:22 AM     httplib_response = conn.getresponse()
today at 11:28:22 AM   File "/usr/local/lib/python3.9/http/client.py", line 1349, in getresponse
today at 11:28:22 AM     response.begin()
today at 11:28:22 AM   File "/usr/local/lib/python3.9/http/client.py", line 316, in begin
today at 11:28:22 AM     version, status, reason = self._read_status()
today at 11:28:22 AM   File "/usr/local/lib/python3.9/http/client.py", line 285, in _read_status
today at 11:28:22 AM     raise RemoteDisconnected("Remote end closed connection without"
today at 11:28:22 AM http.client.RemoteDisconnected: Remote end closed connection without response
today at 11:28:22 AM
today at 11:28:22 AM During handling of the above exception, another exception occurred:
today at 11:28:22 AM
today at 11:28:22 AM Traceback (most recent call last):
today at 11:28:22 AM   File "/usr/local/lib/python3.9/site-packages/requests/adapters.py", line 439, in send
today at 11:28:22 AM     resp = conn.urlopen(
today at 11:28:22 AM   File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 755, in urlopen
today at 11:28:22 AM     retries = retries.increment(
today at 11:28:22 AM   File "/usr/local/lib/python3.9/site-packages/urllib3/util/retry.py", line 532, in increment
today at 11:28:22 AM     raise six.reraise(type(error), error, _stacktrace)
today at 11:28:22 AM   File "/usr/local/lib/python3.9/site-packages/urllib3/packages/six.py", line 769, in reraise
today at 11:28:22 AM     raise value.with_traceback(tb)
today at 11:28:22 AM   File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 699, in urlopen
today at 11:28:22 AM     httplib_response = self._make_request(
today at 11:28:22 AM   File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 445, in _make_request
today at 11:28:22 AM     six.raise_from(e, None)
today at 11:28:22 AM   File "<string>", line 3, in raise_from
today at 11:28:22 AM   File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 440, in _make_request
today at 11:28:22 AM     httplib_response = conn.getresponse()
today at 11:28:22 AM   File "/usr/local/lib/python3.9/http/client.py", line 1349, in getresponse
today at 11:28:22 AM     response.begin()
today at 11:28:22 AM   File "/usr/local/lib/python3.9/http/client.py", line 316, in begin
today at 11:28:22 AM     version, status, reason = self._read_status()
today at 11:28:22 AM   File "/usr/local/lib/python3.9/http/client.py", line 285, in _read_status
today at 11:28:22 AM     raise RemoteDisconnected("Remote end closed connection without"
today at 11:28:22 AM urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
today at 11:28:22 AM
today at 11:28:22 AM During handling of the above exception, another exception occurred:
today at 11:28:22 AM
today at 11:28:22 AM Traceback (most recent call last):
today at 11:28:22 AM   File "/opt/vuegraf/vuegraf.py", line 228, in <module>
today at 11:28:22 AM     influx.write_points(usageDataPoints)
today at 11:28:22 AM   File "/usr/local/lib/python3.9/site-packages/influxdb/client.py", line 603, in write_points
today at 11:28:22 AM     return self._write_points(points=points,
today at 11:28:22 AM   File "/usr/local/lib/python3.9/site-packages/influxdb/client.py", line 681, in _write_points
today at 11:28:22 AM     self.write(
today at 11:28:22 AM   File "/usr/local/lib/python3.9/site-packages/influxdb/client.py", line 413, in write
today at 11:28:22 AM     self.request(
today at 11:28:22 AM   File "/usr/local/lib/python3.9/site-packages/influxdb/client.py", line 332, in request
today at 11:28:22 AM     response = self._session.request(
today at 11:28:22 AM   File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 542, in request
today at 11:28:22 AM     resp = self.send(prep, **send_kwargs)
today at 11:28:22 AM   File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 655, in send
today at 11:28:22 AM     r = adapter.send(request, **kwargs)
today at 11:28:22 AM   File "/usr/local/lib/python3.9/site-packages/requests/adapters.py", line 498, in send
today at 11:28:22 AM     raise ConnectionError(err, request=request)
today at 11:28:22 AM requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
today at 11:29:23 AM 2021-08-25 15:29:23.070855 | INFO  | Submitting datapoints to database; account="Home"; points=31
jertel commented 3 years ago

Check your influx logs to see if it has a reason for closing the socket.

tgregory86 commented 3 years ago

Thanks, I thought it was being disconnected by the Emporia API side not Influx.

Thanks for all the help today.