Skip to content

Commit

Permalink
Cleanup state data #217
Browse files Browse the repository at this point in the history
  • Loading branch information
danielperna84 committed Nov 8, 2022
1 parent 9e36968 commit 394545b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Version 0.5.2 (2022-11-08)
- Bugfix: Fix page load with special characters in states (Issue #217)

Version 0.5.1 (2022-09-08)
- Bugfix: Disable Ace-internal yaml-linting (Issue #226)
- Disable internal check for new releases
Expand Down
14 changes: 12 additions & 2 deletions hass_configurator/configurator.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
SO.setFormatter(
logging.Formatter('%(levelname)s:%(asctime)s:%(name)s:%(message)s'))
LOG.addHandler(SO)
VERSION = "0.5.1"
VERSION = "0.5.2"
BASEDIR = "."
DEV = False
LISTENPORT = None
Expand Down Expand Up @@ -826,7 +826,17 @@ def do_GET(self):
req = urllib.request.Request("%sstates" % HASS_API,
headers=headers, method='GET')
with urllib.request.urlopen(req) as response:
states = response.read().decode('utf-8')
states_clean = []
for state in json.loads(response.read().decode('utf-8')):
states_clean.append(
{
"entity_id": state.get("entity_id", ""),
"attributes":
{"friendly_name": state.get("attributes", {}).get(
"friendly_name", state.get("entity_id", ""))}
}
)
states = json.dumps(states_clean)

except Exception as err:
LOG.warning("Exception getting bootstrap")
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

NAME = "hass-configurator"
PACKAGE_NAME = "hass_configurator"
VERSION = "0.5.1"
VERSION = "0.5.2"

setup(name=NAME,
version=VERSION,
Expand Down

0 comments on commit 394545b

Please sign in to comment.