Skip to content

Commit

Permalink
Merge pull request #1 from stickpin/v1.1.0
Browse files Browse the repository at this point in the history
v1.1.0
  • Loading branch information
stickpin authored May 22, 2024
2 parents e36bdbe + 9ce6047 commit de46f65
Show file tree
Hide file tree
Showing 9 changed files with 247 additions and 456 deletions.
19 changes: 5 additions & 14 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,17 @@ on:
- "main"

jobs:
validate-black:
name: "black validation"
validate-ruff:
name: With Ruff
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Python 3.11
uses: actions/setup-python@v5
- name: Check ruff
uses: chartboost/ruff-action@v1
with:
python-version: "3.11"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install black
- name: Check lint
run: |
black --check --diff --color --line-length=120 .
args: 'format --diff'

hassfest: # https://developers.home-assistant.io/blog/2020/04/16/hassfest
name: "Hassfest Validation"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![Version](https://img.shields.io/github/v/release/stickpin/homeassistant-meinvodafone)
![Downloads](https://img.shields.io/github/downloads/stickpin/homeassistant-meinvodafone/total)
![CodeStyle](https://img.shields.io/badge/code%20style-black-black)
![CodeStyle](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)
[![CodeQL](https://github.com/stickpin/homeassistant-meinvodafone/actions/workflows/codeql.yml/badge.svg)](https://github.com/stickpin/homeassistant-meinvodafone/actions/workflows/codeql.yml)


Expand Down Expand Up @@ -61,7 +61,7 @@ Currently, integration is not part of the HACS, so you will have to add the repo
- Minutes Used/Remaining/Total
- SMS Used/Remaining/Total
- Data Used/Remaining/Total
- Support for multiple packages (Primary/Secondary)
- Support for multiple plans.
- Billing Summary Current/Previous.
- Billing Cycle (days left)

Expand Down
24 changes: 18 additions & 6 deletions custom_components/meinvodafone/MeinVodafoneAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ async def login(self) -> bool:
"User-Agent": USER_AGENT,
}

async with self.session.post(url, headers=headers, json=payload) as response:
async with self.session.post(
url, headers=headers, json=payload
) as response:
_LOGGER.debug("Request URL: %s", url)
_LOGGER.debug("Request headers: %s", headers)
_LOGGER.debug("Response headers: %s", response.headers)
Expand Down Expand Up @@ -97,7 +99,9 @@ async def get_contracts(self) -> list:
"X-Vf-Clientid": X_VF_CLIENT_ID,
}

async with self.session.get(url, headers=headers, allow_redirects=False) as response:
async with self.session.get(
url, headers=headers, allow_redirects=False
) as response:
_LOGGER.debug("Request URL: %s", url)
_LOGGER.debug("Request headers: %s", headers)
_LOGGER.debug("Response headers: %s", response.headers)
Expand All @@ -119,7 +123,9 @@ async def get_contracts(self) -> list:
response.text,
)
except Exception as error:
_LOGGER.error("Error during the contracts retrieval proccess, error %s", error)
_LOGGER.error(
"Error during the contracts retrieval proccess, error %s", error
)
return contracts

async def get_contract_usage(self, contract_number) -> dict:
Expand Down Expand Up @@ -151,7 +157,9 @@ async def get_contract_usage(self, contract_number) -> dict:
"daten": DATA,
}

async with self.session.get(url, headers=headers, allow_redirects=False) as response:
async with self.session.get(
url, headers=headers, allow_redirects=False
) as response:
_LOGGER.debug("Request URL: %s", url)
_LOGGER.debug("Request headers: %s", headers)
_LOGGER.debug("Response headers: %s", response.headers)
Expand All @@ -161,8 +169,12 @@ async def get_contract_usage(self, contract_number) -> dict:
service_usage_vbo = response_data.get("serviceUsageVBO", {})
billing_details = service_usage_vbo.get("billDetails", {})

billing_currect_summary = billing_details.get("currentSummary", {}).get("amount")
billing_last_summary = billing_details.get("lastSummary", {}).get("amount")
billing_currect_summary = billing_details.get(
"currentSummary", {}
).get("amount")
billing_last_summary = billing_details.get("lastSummary", {}).get(
"amount"
)
billing_cycle_start = billing_details.get("billCycleStartDate")
billing_cycle_end = billing_details.get("billCycleEndDate")

Expand Down
Loading

0 comments on commit de46f65

Please sign in to comment.