Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions oligo/asyncio/asynciber.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from deprecated.classic import deprecated

from ..exception import SessionException, ResponseException, NoResponseException, LoginException, \
SelectContractException

Expand Down Expand Up @@ -80,11 +82,21 @@ async def measurement(self) -> dict:
data = await self.__request(WATTHOURMETER_URL)
return {
"id": data["codSolicitudTGT"],
"meter": data["valLecturaContador"],
"consumption": data["valMagnitud"],
"icp": data["valInterruptor"],
"raw_response": data,
}

async def current_kilowatt_hour_read(self) -> float:
"""Returns the current read of the electricity meter."""
return (await self.measurement())["meter"]

async def current_power_consumption(self) -> float:
"""Returns your current power consumption."""
return (await self.measurement())["consumption"]

@deprecated("Use 'current_power_consumption' method instead")
async def watthourmeter(self) -> float:
"""Returns your current power consumption."""
return (await self.measurement())["consumption"]
Expand Down
16 changes: 14 additions & 2 deletions oligo/requests/iber.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from datetime import datetime

from deprecated.classic import deprecated

try:
from requests import Session
except ImportError:
Expand Down Expand Up @@ -64,15 +66,25 @@ def measurement(self):
json_response = response.json()
return {
"id": json_response['codSolicitudTGT'],
"meter": json_response["valLecturaContador"],
"consumption": json_response['valMagnitud'],
"icp": json_response['valInterruptor'],
"raw_response" : json_response
"raw_response": json_response
}

def watthourmeter(self):
def current_kilowatt_hour_read(self):
"""Returns the current read of the electricity meter."""
return self.measurement()["meter"]

def current_power_consumption(self):
"""Returns your current power consumption."""
return self.measurement()['consumption']

@deprecated("Use 'current_power_consumption' method instead")
def watthourmeter(self):
"""Returns your current power consumption."""
return self.current_power_consumption()

def icpstatus(self):
"""Returns the status of your ICP."""
self.__check_session()
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
requests
requests-mock
aiohttp
aiohttp
deprecated
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
long_description_content_type="text/markdown",
url="https://github.com/hectorespert/python-oligo",
packages=find_packages(),
install_requires=[],
install_requires=[
'deprecated'
],
extras_require={
'requests': ['requests'],
'asyncio': ['aiohttp']
Expand Down