Update braintree_gov_uk.py (#1911)

* Update braintree_gov_uk.py

Only the first fetch after a HA reboot would work, added a re-initialize of self.form_data upon every fetch and this now works

* Update braintree_gov_uk.py

"Green Bin" has now been changed to "Garden Bin"
This commit is contained in:
amildenhall
2024-03-27 10:58:49 +00:00
committed by GitHub
parent 5590e06b9b
commit 49f7c96527

View File

@@ -16,7 +16,7 @@ TEST_CASES = {
ICON_MAP = {
"Grey Bin": "mdi:trash-can",
"Clear Sack": "mdi:recycle",
"Green Bin": "mdi:leaf",
"Garden Bin": "mdi:leaf",
"Food Bin": "mdi:food-apple",
}
@@ -26,12 +26,15 @@ class Source:
self.post_code = post_code
self.house_number = house_number
self.url = f"{URL}/xfp/form/554"
def initialize_form_data(self):
self.form_data = {
"qe15dda0155d237d1ea161004d1839e3369ed4831_0_0": (None, post_code),
"qe15dda0155d237d1ea161004d1839e3369ed4831_0_0": (None, self.post_code),
"page": (None, 5730),
}
def fetch(self):
self.initialize_form_data() # Re-initialize form data before each fetch otherwise subsequent fetchs fail
address_lookup = requests.post(
"https://www.braintree.gov.uk/xfp/form/554", files=self.form_data
)