We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
AU battery returning type error
```
fetch_production("AUS-SA") ->
Traceback (most recent call last):
  File "AU.py", line 558, in <module>
    print(fetch_production('AUS-SA'))
  File "AU.py", line 422, in fetch_production
    data['storage']['battery'] = AU_battery.fetch_SA_battery()
  File "/home/chris/electricitymap/parsers/lib/AU_battery.py", line 30, in fetch_SA_battery
    latest = json.loads(data[-1])
  File "/usr/lib/python3.5/json/__init__.py", line 312, in loads
    s.__class__.__name__))
TypeError: the JSON object must be str, not 'bytes'
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `parsers/lib/AU_battery.py`
Content:
```
1 #!/usr/bin/env python3
2 
3 """Parser for South Australia's 129MWh battery built by Tesla."""
4 import arrow
5 import json
6 import requests
7 
8 # nemlog_url gets generation status in 5 min intervals.
9 
10 
11 def fetch_SA_battery(session=None):
12     """
13     Makes a request to the nemlog api for South Australia battery data.
14     Returns a float or None.
15     """
16 
17     today = arrow.now('Australia/Adelaide')
18     current = today.format('YYYYMMDD')
19     old = today.shift(days=-2).format('YYYYMMDD')
20     nemlog_url = 'http://nemlog.com.au/api/unit/HPRL1/{}/{}/json'.format(old, current)
21 
22     s = session or requests.Session()
23     req = s.get(nemlog_url)
24 
25     data = []
26     for line in req.iter_lines():
27         data.append(line)
28 
29     try:
30         latest = json.loads(data[-1])
31     except IndexError:
32         # No data available.
33         return None
34 
35     state = float(latest["SCADAVALUE"])
36 
37     # Source classifies charge/discharge opposite to EM.
38     battery_status = -1 * state
39 
40     return battery_status
41 
42 
43 if __name__ == '__main__':
44     print('fetch_SA_battery() ->')
45     print(fetch_SA_battery())
46
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/parsers/lib/AU_battery.py b/parsers/lib/AU_battery.py
--- a/parsers/lib/AU_battery.py
+++ b/parsers/lib/AU_battery.py
@@ -21,11 +21,9 @@
 
     s = session or requests.Session()
     req = s.get(nemlog_url)
-
     data = []
-    for line in req.iter_lines():
+    for line in req.iter_lines(decode_unicode=True):
         data.append(line)
-
     try:
         latest = json.loads(data[-1])
     except IndexError:

{"golden_diff": "diff --git a/parsers/lib/AU_battery.py b/parsers/lib/AU_battery.py\n--- a/parsers/lib/AU_battery.py\n+++ b/parsers/lib/AU_battery.py\n@@ -21,11 +21,9 @@\n \n     s = session or requests.Session()\n     req = s.get(nemlog_url)\n-\n     data = []\n-    for line in req.iter_lines():\n+    for line in req.iter_lines(decode_unicode=True):\n         data.append(line)\n-\n     try:\n         latest = json.loads(data[-1])\n     except IndexError:\n", "issue": "AU battery returning type error\n```\r\nfetch_production(\"AUS-SA\") ->\r\nTraceback (most recent call last):\r\n  File \"AU.py\", line 558, in <module>\r\n    print(fetch_production('AUS-SA'))\r\n  File \"AU.py\", line 422, in fetch_production\r\n    data['storage']['battery'] = AU_battery.fetch_SA_battery()\r\n  File \"/home/chris/electricitymap/parsers/lib/AU_battery.py\", line 30, in fetch_SA_battery\r\n    latest = json.loads(data[-1])\r\n  File \"/usr/lib/python3.5/json/__init__.py\", line 312, in loads\r\n    s.__class__.__name__))\r\nTypeError: the JSON object must be str, not 'bytes'\r\n```\n", "before_files": [{"content": "#!/usr/bin/env python3\n\n\"\"\"Parser for South Australia's 129MWh battery built by Tesla.\"\"\"\nimport arrow\nimport json\nimport requests\n\n# nemlog_url gets generation status in 5 min intervals.\n\n\ndef fetch_SA_battery(session=None):\n    \"\"\"\n    Makes a request to the nemlog api for South Australia battery data.\n    Returns a float or None.\n    \"\"\"\n\n    today = arrow.now('Australia/Adelaide')\n    current = today.format('YYYYMMDD')\n    old = today.shift(days=-2).format('YYYYMMDD')\n    nemlog_url = 'http://nemlog.com.au/api/unit/HPRL1/{}/{}/json'.format(old, current)\n\n    s = session or requests.Session()\n    req = s.get(nemlog_url)\n\n    data = []\n    for line in req.iter_lines():\n        data.append(line)\n\n    try:\n        latest = json.loads(data[-1])\n    except IndexError:\n        # No data available.\n        return None\n\n    state = float(latest[\"SCADAVALUE\"])\n\n    # Source classifies charge/discharge opposite to EM.\n    battery_status = -1 * state\n\n    return battery_status\n\n\nif __name__ == '__main__':\n    print('fetch_SA_battery() ->')\n    print(fetch_SA_battery())\n", "path": "parsers/lib/AU_battery.py"}], "after_files": [{"content": "#!/usr/bin/env python3\n\n\"\"\"Parser for South Australia's 129MWh battery built by Tesla.\"\"\"\nimport arrow\nimport json\nimport requests\n\n# nemlog_url gets generation status in 5 min intervals.\n\n\ndef fetch_SA_battery(session=None):\n    \"\"\"\n    Makes a request to the nemlog api for South Australia battery data.\n    Returns a float or None.\n    \"\"\"\n\n    today = arrow.now('Australia/Adelaide')\n    current = today.format('YYYYMMDD')\n    old = today.shift(days=-2).format('YYYYMMDD')\n    nemlog_url = 'http://nemlog.com.au/api/unit/HPRL1/{}/{}/json'.format(old, current)\n\n    s = session or requests.Session()\n    req = s.get(nemlog_url)\n    data = []\n    for line in req.iter_lines(decode_unicode=True):\n        data.append(line)\n    try:\n        latest = json.loads(data[-1])\n    except IndexError:\n        # No data available.\n        return None\n\n    state = float(latest[\"SCADAVALUE\"])\n\n    # Source classifies charge/discharge opposite to EM.\n    battery_status = -1 * state\n\n    return battery_status\n\n\nif __name__ == '__main__':\n    print('fetch_SA_battery() ->')\n    print(fetch_SA_battery())\n", "path": "parsers/lib/AU_battery.py"}]}