updates to 0.115.5

This commit is contained in:
Mahasri Kalavala
2020-09-29 22:36:02 -04:00
parent 86d1f32caf
commit b21706d3cd
14 changed files with 402 additions and 775 deletions

View File

@@ -18,9 +18,9 @@ from homeassistant.const import (
CONF_SENSORS,
CONF_SSL,
CONTENT_TYPE_JSON,
PERCENTAGE,
TEMP_CELSIUS,
TIME_SECONDS,
UNIT_PERCENTAGE,
)
from homeassistant.helpers import discovery
import homeassistant.helpers.config_validation as cv
@@ -76,7 +76,7 @@ SENSOR_TYPES = {
"job",
"progress",
"completion",
UNIT_PERCENTAGE,
PERCENTAGE,
"mdi:file-percent",
],
"Time Remaining": [
@@ -146,9 +146,10 @@ def setup(hass, config):
for printer in config[DOMAIN]:
name = printer[CONF_NAME]
ssl = "s" if printer[CONF_SSL] else ""
base_url = "http{}://{}:{}{}api/".format(
ssl, printer[CONF_HOST], printer[CONF_PORT], printer[CONF_PATH]
protocol = "https" if printer[CONF_SSL] else "http"
base_url = (
f"{protocol}://{printer[CONF_HOST]}:{printer[CONF_PORT]}"
f"{printer[CONF_PATH]}api/"
)
api_key = printer[CONF_API_KEY]
number_of_tools = printer[CONF_NUMBER_OF_TOOLS]
@@ -230,7 +231,6 @@ class OctoPrintAPI:
return self.printer_last_reading[0]
url = self.api_url + endpoint
try:
response = requests.get(url, headers=self.headers, timeout=9)
response.raise_for_status()