grahamwetzler / smart-meter-texas

Package to connect to and retrieve data from the unoffical Smart Meter Texas API
MIT License
12 stars 13 forks source link

get_15min does not handle 'consumption' data #136

Open utdrmac opened 11 months ago

utdrmac commented 11 months ago

Description

I'm using the example get_meter_reading.py, except I changed line 36 to await meter.get_15min(client) and added print(f"{meter.read_15min}"). This is the output:

$ python3 meter_reading.py
DEBUG:asyncio:Using selector: EpollSelector
DEBUG:smart_meter_texas:Found CA Issuers URI value: http://cacerts.digicert.com/DigiCertTLSRSASHA2562020CA1-1.crt
DEBUG:smart_meter_texas:Loaded certificate file into SSL Context
Authenticating...
DEBUG:smart_meter_texas:Requesting login token
DEBUG:smart_meter_texas:Successfully retrieved login token
Reading meter...
DEBUG:smart_meter_texas:Getting Interval data
ERROR:smart_meter_texas:Error reading data:
DEBUG:smart_meter_texas:Getting Interval data
DEBUG:smart_meter_texas:Getting Interval data
DEBUG:smart_meter_texas:Getting Interval data     <--- line repeats forever, every 2-4 seconds.

After 5 minutes of seeing that same output, I did ctrl-c to stop it.

Is there an update to this aspect? Different API endpoint? Or do you have a working example?

utdrmac commented 11 months ago

Looks like this func doesn't parse the returned data correctly. The line if entry["RT"] == "G" is the only case it is testing for, yet my data does not contain this value.

[{'DT': '07/20/2023', 'RevTS': '07/20/2023 13:12:00', 'RT': 'C', 'RD': '.17-A,.801-A,.457-A,.186-A,.684-A,.543-A,.171-A,.458-A,,,,,.73-A,.181-A,.295-A,.847-A,.164-A,.152-A,.831-A,.321-A,.185-A,.185-A,.933-A,.184-A,.179-A,.292-A,.731-A,.141-A,.158-A,.432-A,.617-A,.185-A,.185-A,.322-A,.695-A,.148-A,.144-A,.15-A,.836-A,.188-A,.185-A,.184-A,.888-A,.187-A,.186-A,.175-A,.95-A,.164-A,.173-A,.994-A,.178-A,.163-A,1.095-A,.279-A,.265-A,1.218-A,.161-A,.552-A,1.121-A,.182-A,.807-A,.939-A,.182-A,1.078-A,.782-A,.175-A,1.277-A,1.304-A,1.321-A,1.338-A,1.345-A,.99-A,1.558-A,1.451-A,1.307-A,1.296-A,.346-A,1.165-A,1.367-A,.68-A,1.073-A,1.323-A,1.319-A,1.267-A,1.244-A,.545-A,.834-A,1.198-A,.667-A,2.268-A,1.427-A,.537-A,1.225-A,.331-A,.862-A,.73-A,.324-A,1.205-A,.202-A,.515-A'}]

Looking at the SMT.com JS, r = "C" === a.RT ? "Consumption" : "Surplus Generation";

It seems this get_15min func only handles the situation where you generate surplus, and not also handling consumption.