Skip to content

Commit

Permalink
Merge pull request #80 from gtdiehl/gen_passwd
Browse files Browse the repository at this point in the history
Use library to generate and consume password
  • Loading branch information
gtdiehl authored Sep 6, 2021
2 parents d4c7ce5 + 93409df commit 3b0ee3b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions envoy_reader/envoy_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import re
import time
from json.decoder import JSONDecodeError
from envoy_utils.envoy_utils import EnvoyUtils

import httpx

Expand Down Expand Up @@ -163,7 +164,6 @@ async def detect_model(self):
# number as the password. Otherwise use the password argument value.
if self.password == "" and not self.serial_number_last_six:
await self.get_serial_number()
self.password = self.serial_number_last_six

try:
await self._update_from_pc_endpoint()
Expand Down Expand Up @@ -217,7 +217,11 @@ async def get_serial_number(self):
"""Method to get last six digits of Envoy serial number for auth"""
full_serial = await self.get_full_serial_number()
if full_serial:
self.serial_number_last_six = full_serial[-6:]
gen_passwd = EnvoyUtils.get_password(full_serial, self.username)
if self.username == "envoy" or self.username != "installer":
self.password = self.serial_number_last_six = full_serial[-6:]
else:
self.password = gen_passwd

async def get_full_serial_number(self):
"""Method to get the Envoy serial number."""
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"wheel>=0.34.2",
]

requirements = ["httpx>=0.12.1"]
requirements = ["httpx>=0.12.1", "envoy_utils>=0.0.1"]

extra_requirements = {
"setup": setup_requirements,
Expand All @@ -50,7 +50,7 @@

setuptools.setup(
name="envoy_reader",
version="0.19.0",
version="0.20.0",
author="Jesse Rizzo",
author_email="[email protected]",
description="A program to read from an Enphase Envoy on the local network",
Expand Down

0 comments on commit 3b0ee3b

Please sign in to comment.