Created
April 23, 2017 16:08
-
-
Save jvolkman/1068504ca686182dd38e62f036daaf30 to your computer and use it in GitHub Desktop.
OpenHAB Thing.json cleanup script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json; | |
import collections; | |
with open("org.eclipse.smarthome.core.thing.Thing.json", 'r') as f: | |
db = json.load(f, object_pairs_hook=collections.OrderedDict) | |
for thing in db.values(): | |
properties = thing.get("value", {}).get("configuration", {}).get("properties") | |
if not properties: | |
continue | |
for key in properties: | |
if 'group_org.openhab.binding.zwave.internal.protocol.ZWaveAssociationGroup' in key: | |
del properties[key] | |
with open("org.eclipse.smarthome.core.thing.Thing.json.clean", 'w') as f: | |
json.dump(db, f, indent=2, separators=(',', ': ')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment