Use RESTful Sensor?

I did a packet capture and found the url that my iOS app uses in order to get the bin information/schedule.
http://ci.draftserver.com/penrith/webservice/location/search

How would I go about using this in home assistant to post/fill in the form and then fetch the data?

Random address that could be used to test:
House Number: 38
Suburb: penrith
Address: mulgoa road

check this very similar post:

1 Like

I just ran this from Linux

curl 'http://ci.draftserver.com/penrith/webservice/location/search' -H 'Connection: keep-alive' -H 'Cache-Control: max-age=0' -H 'Origin: http://ci.draftserver.com' -H 'Upgrade-Insecure-Requests: 1' -H 'Content-Type: application/x-www-form-urlencoded' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8' -H 'Referer: http://ci.draftserver.com/penrith/webservice/location/search?st_number=38&suburb=penrith&address=mulgoa+road&offset=' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: en-US,en;q=0.9' --data 'st_number=38&suburb=penrith&address=mulgoa+road&offset=' --compressed

And got this result

{"code":"0001","msg":"Success","offset":1000,"total":"1","results":[{"unit_number":"0","house_number":"38","street":"Mulgoa","street_type":"Road","suburb":"PENRITH","postcode":"2750","collection_day":"TuesA2","bin_type":"3","dwelling":"single","date_time":"0000-00-00 00:00:00","current_week_type":"EVEN","bin_colors":"1,2,3","collection_frequencies":"2,1,2","area":"2","item_garbage":"2018-06-26","item_recycling":"2018-06-19","item_organic":"2018-06-19"}]}

Thanks for your assistance.

Sorry, very new here with home assistant and coding. Is there an easy way to have this information imported into home assistant?

I’ve converted the above curl command into a python script and I’ve been testing it on my Windows machine. I can get it to post and get the json data or print the info.

{"code": "0001", "msg": "Success", "offset": 1000, "total": "1", "results": [{"unit_number": "0", "house_number": "38", "street": "Mulgoa", "street_type": "Road", "suburb": "PENRITH", "postcode": "2750", "collection_day": "TuesA2", "bin_type": "3", "dwelling": "single", "date_time": "0000-00-00 00:00:00", "current_week_type": "EVEN", "bin_colors": "1,2,3", "collection_frequencies": "2,1,2", "area": "2", "item_garbage": "2018-06-26", "item_recycling": "2018-06-19", "item_organic": "2018-06-19"}]}

What would be the best way to implement this in Home Assistant so that the json data is imported into Home Assistant. I can get to the information fine and print it.
response = requests.post('http://ci.draftserver.com/penrith/webservice/location/search', headers=headers, data=data)
data = response.text
json_object = json.loads(data)
print(json_object['results'][0]['item_garbage'])
print(json_object['results'][0]['item_recycling'])
print(json_object['results'][0]['item_organic'])

I then thought maybe I could schedule a daily run of the python script and save the to say data.json to /config/www/ and the process the file with home assistant so that it’s an entity and the information is taken and added as an attribute of the entity… just not getting anywhere.

Open to any suggestion.