Print all keys
This commit is contained in:
parent
5acc81acc3
commit
c4d21be388
@ -24,6 +24,7 @@ def get_arguments():
|
|||||||
subparser = parser.add_subparsers(title="commands", metavar="COMMAND")
|
subparser = parser.add_subparsers(title="commands", metavar="COMMAND")
|
||||||
keys = subparser.add_parser("keys", help="print as key format")
|
keys = subparser.add_parser("keys", help="print as key format")
|
||||||
keys.add_argument("keys", help="print as key format", action="store_true")
|
keys.add_argument("keys", help="print as key format", action="store_true")
|
||||||
|
keys.add_argument("--all", help="print also full keys", action="store_true")
|
||||||
return vars(parser.parse_args())
|
return vars(parser.parse_args())
|
||||||
|
|
||||||
|
|
||||||
@ -90,9 +91,12 @@ async def main():
|
|||||||
for device in hon.devices:
|
for device in hon.devices:
|
||||||
print("=" * 10, device.appliance_type, "-", device.nick_name, "=" * 10)
|
print("=" * 10, device.appliance_type, "-", device.nick_name, "=" * 10)
|
||||||
if args.get("keys"):
|
if args.get("keys"):
|
||||||
key_print(device.data["attributes"]["parameters"])
|
data = device.data.copy()
|
||||||
key_print(device.data["appliance"])
|
attr = "get" if args.get("all") else "pop"
|
||||||
key_print(device.data)
|
key_print(data["attributes"].__getattribute__(attr)("parameters"))
|
||||||
|
key_print(data.__getattribute__(attr)("appliance"))
|
||||||
|
key_print(data.__getattribute__(attr)("commands"))
|
||||||
|
key_print(data)
|
||||||
pretty_print(create_command(device.commands, concat=True))
|
pretty_print(create_command(device.commands, concat=True))
|
||||||
else:
|
else:
|
||||||
pretty_print({"data": device.data})
|
pretty_print({"data": device.data})
|
||||||
|
@ -5,4 +5,5 @@ class Appliance:
|
|||||||
def get(self):
|
def get(self):
|
||||||
if self._data["attributes"]["lastConnEvent"]["category"] == "DISCONNECTED":
|
if self._data["attributes"]["lastConnEvent"]["category"] == "DISCONNECTED":
|
||||||
self._data["attributes"]["parameters"]["machMode"] = "0"
|
self._data["attributes"]["parameters"]["machMode"] = "0"
|
||||||
|
self._data["active"] = bool(self._data.get("activity"))
|
||||||
return self._data
|
return self._data
|
||||||
|
@ -33,6 +33,13 @@ class HonDevice:
|
|||||||
return self.data[item]
|
return self.data[item]
|
||||||
return self.attributes["parameters"].get(item, self.appliance[item])
|
return self.attributes["parameters"].get(item, self.appliance[item])
|
||||||
|
|
||||||
|
def get(self, item, default=None):
|
||||||
|
try:
|
||||||
|
return self[item]
|
||||||
|
except KeyError | IndexError:
|
||||||
|
return default
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def appliance_model_id(self):
|
def appliance_model_id(self):
|
||||||
return self._appliance.get("applianceModelId")
|
return self._appliance.get("applianceModelId")
|
||||||
|
2
setup.py
2
setup.py
@ -7,7 +7,7 @@ with open("README.md", "r") as f:
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="pyhOn",
|
name="pyhOn",
|
||||||
version="0.3.0",
|
version="0.3.1",
|
||||||
author="Andre Basche",
|
author="Andre Basche",
|
||||||
description="Control hOn devices with python",
|
description="Control hOn devices with python",
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
|
Loading…
Reference in New Issue
Block a user