Skip to content

Commit

Permalink
Revert changes between v1.02 and v1.03
Browse files Browse the repository at this point in the history
  • Loading branch information
turbokongen committed Apr 6, 2020
1 parent 6f880c5 commit 31f6d93
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
2 changes: 1 addition & 1 deletion custom_components/ams/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class AmsHub:
def __init__(self, hass, entry):
"""Initialize the AMS hub."""
self._hass = hass
port = (entry.data[CONF_SERIAL_PORT].split(':'))[0]
port = entry.data[CONF_SERIAL_PORT]
_LOGGER.debug(port)
parity = entry.data[CONF_PARITY]
self.meter_manufacturer = entry.data[CONF_METER_MANUFACTURER]
Expand Down
15 changes: 3 additions & 12 deletions custom_components/ams/config_flow.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Adds config flow for hass-HAN."""

import serial.tools.list_ports as devices
import voluptuous as vol
from homeassistant import config_entries

Expand All @@ -11,8 +10,7 @@
CONF_PARITY,
DEFAULT_SERIAL_PORT,
DEFAULT_METER_MANUFACTURER,
DEFAULT_PARITY,
_LOGGER
DEFAULT_PARITY
)


Expand All @@ -26,27 +24,20 @@ class AmsFlowHandler(config_entries.ConfigFlow):
def __init__(self):
"""Initialize."""
self._errors = {}
self.ports = [
(comport.device + ": " + comport.description)
for comport in devices.comports()]

async def async_step_user(self, user_input=None):
"""Handle a flow initialized by the user."""

if user_input is not None:
return self.async_create_entry(
title="Norwegian AMS", data=user_input)
_LOGGER.debug(self.ports)
return self.async_show_form(step_id="user", data_schema=vol.Schema({
vol.Required(CONF_SERIAL_PORT,
default=None): vol.In(self.ports),
default=None): vol.All(str),
vol.Required(CONF_METER_MANUFACTURER,
default=DEFAULT_METER_MANUFACTURER): vol.All(str),
vol.Optional(CONF_PARITY, default=DEFAULT_PARITY): vol.All(str)
}),
description_placeholders={
CONF_SERIAL_PORT: self.ports,
}, errors=self._errors)
}), errors=self._errors)

async def async_step_import(self, user_input=None):
"""Import a config flow from configuration."""
Expand Down

0 comments on commit 31f6d93

Please sign in to comment.