././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1688766732.073564 goalzero-0.2.2/0000755000175100001730000000000014452104414012735 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1688766723.0 goalzero-0.2.2/LICENSE0000644000175100001730000000205614452104403013743 0ustar00runnerdockerMIT License Copyright (c) 2020 Robert Hillis Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1688766732.073564 goalzero-0.2.2/PKG-INFO0000644000175100001730000000123114452104414014027 0ustar00runnerdockerMetadata-Version: 2.1 Name: goalzero Version: 0.2.2 Summary: Goal Zero REST Api Library Home-page: https://github.com/tkdrob/goalzero Author: Robert Hillis Author-email: tkdrob4390@yahoo.com Classifier: Programming Language :: Python :: 3 Classifier: License :: OSI Approved :: MIT License Classifier: Operating System :: OS Independent Requires-Python: >=3.6 Description-Content-Type: text/markdown License-File: LICENSE # Goal Zero Yeti REST Api Library Credit to Nicholas Andre for procuring the REST api info from Goal Zero: https://blog.nicholasandre.com/goal-zero-yeti-local-wifi-rest-api/ Thanks to Goal Zero for thinking of us techies by providing this. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1688766723.0 goalzero-0.2.2/README.md0000644000175100001730000000036214452104403014213 0ustar00runnerdocker# Goal Zero Yeti REST Api Library Credit to Nicholas Andre for procuring the REST api info from Goal Zero: https://blog.nicholasandre.com/goal-zero-yeti-local-wifi-rest-api/ Thanks to Goal Zero for thinking of us techies by providing this. ././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1688766732.073564 goalzero-0.2.2/goalzero/0000755000175100001730000000000014452104414014557 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1688766723.0 goalzero-0.2.2/goalzero/__init__.py0000644000175100001730000001261114452104403016667 0ustar00runnerdocker""" Goal Zero Rest Api ~~~~~~~~~~~~~~~~~~~~~ :copyright: (c) 2020 by Robert Hillis. Not affiliated with Goal Zero. Credit for headers belongs to Goal Zero. :license: Apache 2.0, see LICENSE for more details. """ import asyncio import aiohttp from . import exceptions HEADER = { "Content-Type": "application/json", "User-Agent": "YetiApp/1340 CFNetwork/1125.2 Darwin/19.4.0", "Connection": "keep-alive", "Accept": "application/json", "Accept-Language": "en-us", "Accept-Encoding": "gzip, deflate", "Cache-Control": "no-cache", } TIMEOUT = 10 semaphore = asyncio.Semaphore() class Yeti: """A class for handling connections with a Goal Zero Yeti.""" def __init__(self, host: str, session: aiohttp.ClientSession, **data) -> None: """Initialize the connection to Goal Zero Yeti instance.""" self._session = session self.control = {} self.data = {} self.endpoint = {} self.host = host self.payload = {} self.mac = None self.sysdata = {} async def init_connect(self) -> None: """Get states from Goal Zero Yeti instance.""" self.endpoint = "/sysinfo" self.control = "name" await Yeti.send_get(self) self.control = "thingName" self.endpoint = "/state" await Yeti.send_get(self) async def get_state(self) -> None: """Get states from Goal Zero Yeti instance.""" self.control = "thingName" self.endpoint = "/state" await Yeti.send_get(self) async def post_state(self, payload) -> None: """Post payload to Goal Zero Yeti instance.""" self.endpoint = "/state" self.payload = payload await Yeti.send_post(self) async def sysinfo(self) -> None: """Get system info from Goal Zero Yeti instance.""" self.endpoint = "/sysinfo" self.control = "name" await Yeti.send_get(self) async def reset(self) -> None: """Reset Goal Zero Yeti instance.""" self.endpoint = "/factory-reset" await Yeti.send_get(self) async def reboot(self) -> None: """Reboot Goal Zero Yeti instance.""" self.endpoint = "/rpc/Sys.Reboot" await Yeti.send_get(self) async def get_loglevel(self) -> None: """Get log level Goal Zero Yeti instance.""" self.endpoint = "/loglevel" self.control = "app" await Yeti.send_get(self) async def post_loglevel(self, payload) -> None: """Post log level Goal Zero Yeti instance.""" self.endpoint = "/loglevel" self.payload = payload await Yeti.send_post(self) async def join(self, payload) -> None: """Join Goal Zero Yeti instance to Wifi network.""" self.endpoint = "/join" self.payload = payload await Yeti.send_post(self) async def wifi(self) -> None: """Get available Wifi networks visible to Goal Zero Yeti instance.""" self.endpoint = "/wifi" await Yeti.send_get(self) async def password_set(self, payload) -> None: """Set password to Zero Yeti instance.""" self.payload = {"new_password": "" + payload + ""} self.endpoint = "/password-set" await Yeti.send_post(self) async def join_direct(self) -> None: """Directly Join Goal Zero Yeti instance on its Wifi.""" self.endpoint = "/join-direct" await Yeti.send_post(self) async def start_pair(self) -> None: """Pair with Goal Zero Yeti instance.""" self.endpoint = "/start-pair" await Yeti.send_post(self) async def send_get(self) -> None: """Send get request.""" try: async with semaphore: response = await self._session.get( url=f"http://{self.host}{self.endpoint}", timeout=aiohttp.ClientTimeout(TIMEOUT), ) if self.endpoint == "/sysinfo": self.sysdata = await response.json() else: self.data = await response.json() if self.control not in self.data.keys(): raise exceptions.InvalidHost() if self.data["socPercent"] > 100: self.data["socPercent"] = 100 except ( OSError, TypeError, aiohttp.client_exceptions.ClientConnectorError, asyncio.exceptions.TimeoutError, ) as err: raise exceptions.ConnectError() from err except aiohttp.client_exceptions.ServerDisconnectedError: pass async def send_post(self) -> None: """Send post request.""" try: async with semaphore: request = await self._session.post( url=f"http://{self.host}{self.endpoint}", json=self.payload, headers=HEADER, timeout=aiohttp.ClientTimeout(TIMEOUT), ) self.data = await request.json() if self.data["socPercent"] > 100: self.data["socPercent"] = 100 except ( OSError, TypeError, aiohttp.client_exceptions.ClientConnectorError, asyncio.exceptions.TimeoutError, ) as err: raise exceptions.ConnectError() from err except aiohttp.client_exceptions.ServerDisconnectedError: pass ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1688766723.0 goalzero-0.2.2/goalzero/exceptions.py0000644000175100001730000000033214452104403017306 0ustar00runnerdocker"""Exceptions for Goal Zero Yeti API Python client""" class ConnectError(Exception): """When a connection error is encountered.""" class InvalidHost(Exception): """The URL provided was somehow invalid.""" ././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1688766732.073564 goalzero-0.2.2/goalzero.egg-info/0000755000175100001730000000000014452104414016251 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1688766732.0 goalzero-0.2.2/goalzero.egg-info/PKG-INFO0000644000175100001730000000123114452104414017343 0ustar00runnerdockerMetadata-Version: 2.1 Name: goalzero Version: 0.2.2 Summary: Goal Zero REST Api Library Home-page: https://github.com/tkdrob/goalzero Author: Robert Hillis Author-email: tkdrob4390@yahoo.com Classifier: Programming Language :: Python :: 3 Classifier: License :: OSI Approved :: MIT License Classifier: Operating System :: OS Independent Requires-Python: >=3.6 Description-Content-Type: text/markdown License-File: LICENSE # Goal Zero Yeti REST Api Library Credit to Nicholas Andre for procuring the REST api info from Goal Zero: https://blog.nicholasandre.com/goal-zero-yeti-local-wifi-rest-api/ Thanks to Goal Zero for thinking of us techies by providing this. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1688766732.0 goalzero-0.2.2/goalzero.egg-info/SOURCES.txt0000644000175100001730000000034514452104414020137 0ustar00runnerdockerLICENSE README.md setup.py goalzero/__init__.py goalzero/exceptions.py goalzero.egg-info/PKG-INFO goalzero.egg-info/SOURCES.txt goalzero.egg-info/dependency_links.txt goalzero.egg-info/requires.txt goalzero.egg-info/top_level.txt././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1688766732.0 goalzero-0.2.2/goalzero.egg-info/dependency_links.txt0000644000175100001730000000000114452104414022317 0ustar00runnerdocker ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1688766732.0 goalzero-0.2.2/goalzero.egg-info/requires.txt0000644000175100001730000000001714452104414020647 0ustar00runnerdockeraiohttp>=3.4.4 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1688766732.0 goalzero-0.2.2/goalzero.egg-info/top_level.txt0000644000175100001730000000001114452104414020773 0ustar00runnerdockergoalzero ././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1688766732.073564 goalzero-0.2.2/setup.cfg0000644000175100001730000000004614452104414014556 0ustar00runnerdocker[egg_info] tag_build = tag_date = 0 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1688766730.0 goalzero-0.2.2/setup.py0000644000175100001730000000127714452104412014454 0ustar00runnerdocker#!/usr/bin/env python import setuptools with open("README.md", "r") as fh: long_description = fh.read() setuptools.setup( name="goalzero", version="v0.2.2", author="Robert Hillis", author_email="tkdrob4390@yahoo.com", description="Goal Zero REST Api Library", long_description=long_description, long_description_content_type="text/markdown", url="https://github.com/tkdrob/goalzero", packages=setuptools.find_packages(), install_requires=['aiohttp>=3.4.4'], classifiers=[ "Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", ], python_requires='>=3.6', )