mirror of
https://github.com/sascha-hemi/hacs_waste_collection_schedule.git
synced 2026-03-21 05:06:33 +01:00
add source tkeliai_lt (#1897)
* add source tkeliai_lt * reformatting --------- Co-authored-by: 5ila5 <5ila5@users.noreply.github.com>
This commit is contained in:
@@ -1005,6 +1005,7 @@ Waste collection schedules in the following formats and countries are supported.
|
||||
<summary>Lithuania</summary>
|
||||
|
||||
- [Kauno švara](/doc/source/grafikai_svara_lt.md) / grafikai.svara.lt
|
||||
- [Telšių keliai](/doc/source/tkeliai_lt.md) / tkeliai.lt
|
||||
</details>
|
||||
|
||||
<details>
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
import datetime
|
||||
import json
|
||||
|
||||
import requests
|
||||
from waste_collection_schedule import Collection # type: ignore[attr-defined]
|
||||
|
||||
TITLE = "Telšių keliai"
|
||||
DESCRIPTION = "Source script for UAB 'Telšių keliai'"
|
||||
URL = "https://tkeliai.lt/"
|
||||
TEST_CASES = {
|
||||
"TestName1": {"location": "Butkų Juzės(1-31) g."},
|
||||
"TestName2": {"location": "Paragai k."},
|
||||
"TestName3": {"location": "Žalioji g."},
|
||||
}
|
||||
|
||||
API_URL = "https://tkeliai.lt/ajax.php"
|
||||
ICON_MAP = {
|
||||
"Mišrios komunalinės atliekos": "mdi:trash-can",
|
||||
"Kitos pakuočių atliekos": "mdi:recycle",
|
||||
"Stiklo pakuočių atliekos": "mdi:glass-fragile",
|
||||
}
|
||||
|
||||
|
||||
class Source:
|
||||
def __init__(self, location):
|
||||
self.location = location
|
||||
|
||||
def fetch(self):
|
||||
data = {
|
||||
"action": "getDataAll",
|
||||
"module": "Atliekos",
|
||||
"lang": "lt",
|
||||
"location": self.location,
|
||||
}
|
||||
headers = {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
"User-Agent": "",
|
||||
}
|
||||
|
||||
response = requests.post(API_URL, headers=headers, data=data)
|
||||
|
||||
data = json.loads(response.text)
|
||||
|
||||
entries = []
|
||||
|
||||
for collection in data["return"]:
|
||||
for date in collection["dates"].keys():
|
||||
entries.append(
|
||||
Collection(
|
||||
date=datetime.datetime.strptime(date, "%Y-%m-%d").date(),
|
||||
t=collection["title"],
|
||||
icon=ICON_MAP.get(collection["title"]),
|
||||
)
|
||||
)
|
||||
|
||||
return entries
|
||||
32
doc/source/tkeliai_lt.md
Normal file
32
doc/source/tkeliai_lt.md
Normal file
@@ -0,0 +1,32 @@
|
||||
# Telšių keliai
|
||||
|
||||
Support for schedules provided by [Telšių keliai](https://tkeliai.lt).
|
||||
|
||||
## Configuration via configuration.yaml
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: tkeliai_lt
|
||||
args:
|
||||
location: LOCATION
|
||||
```
|
||||
|
||||
### Configuration Variables
|
||||
|
||||
**location**
|
||||
*(string) (required)*
|
||||
|
||||
## Example
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: tkeliai_lt
|
||||
args:
|
||||
location: Butkų Juzės(1-31) g.
|
||||
```
|
||||
|
||||
## How to get the source arguments
|
||||
|
||||
Visit the [Atliekų išvežimo grafikas](https://tkeliai.lt/kalendorius/) page and search for your address.
|
||||
Reference in New Issue
Block a user