kimmolinna/pycaruna

Sample code doesn't work

Closed this issue · 3 comments

rhk commented

Sample code:

import pycaruna
session = pycaruna.login("username", "password")
customer = pycaruna.get_current(session)
metering_points = pycaruna.get_metering_points(session, customer)
consumption = pycaruna.get_cons_hours(session, customer, metering_point, "2022-11-01", "2022-11-30")
response = pycaruna.logout(session)

Issue1: 2nd row should be session = pycaruna.login**_caruna**...

Issue2:

Traceback (most recent call last):
  File "/home/rhk/pycaruna_kimmolinna/rcaruna.py", line 5, in <module>
    consumption = pycaruna.get_cons_hours(session, customer, metering_point, "2022-12-01", "2022-12-04")
NameError: name 'metering_point' is not defined. Did you mean: 'metering_points'?

changed to metering_points but got

Traceback (most recent call last):
  File "/home/rhk/pycaruna_kimmolinna/rcaruna.py", line 5, in <module>
    consumption = pycaruna.get_cons_hours(session, customer, metering_points, "2022-12-01", "2022-12-04")
  File "/home/rhk/pycaruna_kimmolinna/pycaruna.py", line 122, in get_cons_hours
    r=s.get("https://energiaseuranta.caruna.fi/api/meteringPoints/ELECTRICITY/"+metering_point+"/series?products=EL_ENERGY_CONSUMPTION&resolution=MONTHS_AS_HOURS&customerNumber="+customer+"&startDate="+start_day+"T00:00:00-0000&endDate="+end_day+"T00:00:00-0000")
TypeError: can only concatenate str (not "list") to str

Issue3: Last row should have pycaruna.logout**_caruna**(session)

Updated example according to caruna.py.

There's still one typo in the README sample code.

Sample code now:
response = pycaruna.logout(session)

Should be:
response = pycaruna.logout_caruna(session)

Cheers,
Markus

Thanks. Fixed.