Skip to content

Commit

Permalink
Added support for setting minimum green level
Browse files Browse the repository at this point in the history
  • Loading branch information
CJNE committed Sep 3, 2021
1 parent a4a785f commit 099e5a0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pymyenergi/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ async def main(args):
sys.exit(f"A mode must be specifed, one of {modes}")
await device.set_charge_mode(args.arg[0])
print(f"Charging was set to {args.arg[0].capitalize()}")
elif args.action == "mingreen":
if len(args.arg) < 1:
sys.exit("A minimum green level must be provided")
await device.set_minimum_green_level(args.arg[0])
print(f"Minimum green level was set to {args.arg[0]}")
elif args.action == "boost":
await device.start_boost(args.arg[0])
print(f"Start boosting with {args.arg[0]}kWh")
Expand Down Expand Up @@ -87,7 +92,7 @@ def cli():
subparser_zappi = subparsers.add_parser("zappi", help="zappi help")
subparser_zappi.add_argument("serial", default=None)
subparser_zappi.add_argument(
"action", choices=["show", "stop", "mode", "boost", "smart-boost"]
"action", choices=["show", "stop", "mode", "boost", "smart-boost", "mingreen"]
)
subparser_zappi.add_argument("arg", nargs="*")

Expand Down
7 changes: 7 additions & 0 deletions pymyenergi/zappi.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,13 @@ async def set_charge_mode(self, mode):
self._data["zmo"] = mode_int
return True

async def set_minimum_green_level(self, level):
"""Set minimum green level 0-100"""
await self._connection.get(f"/cgi-set-min-green-Z{self._serialno}-{level}")
# Set local data if successful
self._data["mgl"] = level
return True

async def start_boost(self, amount):
"""Start boost"""
await self._connection.get(
Expand Down

0 comments on commit 099e5a0

Please sign in to comment.