Skip to content

Commit

Permalink
Remove timeout as configuration parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
binsentsu committed Feb 1, 2020
1 parent ce09b97 commit e6406ba
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 12 deletions.
10 changes: 4 additions & 6 deletions custom_components/solaredge_modbus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@

import homeassistant.helpers.config_validation as cv
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_NAME, CONF_HOST, CONF_PORT, CONF_TIMEOUT, CONF_SCAN_INTERVAL
from homeassistant.const import CONF_NAME, CONF_HOST, CONF_PORT, CONF_SCAN_INTERVAL
from homeassistant.core import HomeAssistant
from homeassistant.core import callback
from homeassistant.helpers.event import async_track_time_interval
from .const import DOMAIN, DEFAULT_NAME, DEFAULT_TIMEOUT, DEFAULT_SCAN_INTERVAL
from .const import DOMAIN, DEFAULT_NAME, DEFAULT_SCAN_INTERVAL

_LOGGER = logging.getLogger(__name__)

Expand All @@ -25,7 +25,6 @@
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
vol.Required(CONF_HOST): cv.string,
vol.Required(CONF_PORT): cv.string,
vol.Optional(CONF_TIMEOUT, default=DEFAULT_TIMEOUT): cv.positive_int,
vol.Optional(CONF_SCAN_INTERVAL, default=DEFAULT_SCAN_INTERVAL): cv.positive_int
}
)
Expand All @@ -48,12 +47,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
host = entry.data[CONF_HOST]
name = entry.data[CONF_NAME]
port = entry.data[CONF_PORT]
timeout = entry.data[CONF_TIMEOUT]
scan_interval = entry.data[CONF_SCAN_INTERVAL]

_LOGGER.debug("Setup %s.%s", DOMAIN, name)

hub = SolaredgeModbusHub(hass, name, host, port, timeout, scan_interval)
hub = SolaredgeModbusHub(hass, name, host, port, scan_interval)
"""Register the hub."""
hass.data[DOMAIN][name] = {
"hub": hub
Expand Down Expand Up @@ -86,7 +84,7 @@ async def async_unload_entry(hass, entry):
class SolaredgeModbusHub:
"""Thread safe wrapper class for pymodbus."""

def __init__(self, hass, name, host, port, timeout, scan_interval):
def __init__(self, hass, name, host, port, scan_interval):
"""Initialize the Modbus hub."""
self._hass = hass
self._client = ModbusTcpClient(host=host, port=port)
Expand Down
5 changes: 2 additions & 3 deletions custom_components/solaredge_modbus/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@
import voluptuous as vol

from homeassistant import config_entries, exceptions
from homeassistant.const import CONF_NAME, CONF_HOST, CONF_PORT, CONF_TIMEOUT, CONF_SCAN_INTERVAL
from .const import DOMAIN, DEFAULT_NAME, DEFAULT_TIMEOUT, DEFAULT_SCAN_INTERVAL, DEFAULT_PORT
from homeassistant.const import CONF_NAME, CONF_HOST, CONF_PORT, CONF_SCAN_INTERVAL
from .const import DOMAIN, DEFAULT_NAME, DEFAULT_SCAN_INTERVAL, DEFAULT_PORT
from homeassistant.core import HomeAssistant, callback

DATA_SCHEMA = vol.Schema(
{
vol.Optional(CONF_NAME, default=DEFAULT_NAME): str,
vol.Required(CONF_HOST): str,
vol.Required(CONF_PORT, default=DEFAULT_PORT): int,
vol.Optional(CONF_TIMEOUT, default=DEFAULT_TIMEOUT): int,
vol.Optional(CONF_SCAN_INTERVAL, default=DEFAULT_SCAN_INTERVAL): int
}
)
Expand Down
1 change: 0 additions & 1 deletion custom_components/solaredge_modbus/const.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
DOMAIN = "solaredge_modbus"
DEFAULT_NAME = "solaredge"
DEFAULT_TIMEOUT = 3
DEFAULT_SCAN_INTERVAL = 30
DEFAULT_PORT = 1502
CONF_SOLAREDGE_HUB = "solaredge_hub"
Expand Down
2 changes: 1 addition & 1 deletion custom_components/solaredge_modbus/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"domain": "solaredge_modbus",
"name": "SolarEdge Modbus",
"documentation": "https://www.home-assistant.io/integrations/solaredge_modbus",
"documentation": "https://github.com/binsentsu/home-assistant-solaredge-modbus",
"requirements": ["pymodbus==1.5.2"],
"dependencies": [],
"codeowners": ["@binsentsu"],
Expand Down
1 change: 0 additions & 1 deletion custom_components/solaredge_modbus/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"host": "The ip-address of your Solaredge device",
"name": "The prefix to be used for your SolarEdge sensors",
"port": "The TCP port on which to connect to the SolarEdge",
"timeout": "The connection timeout",
"scan_interval": "The polling frequentie of the modbus registers in seconds"
}
}
Expand Down

0 comments on commit e6406ba

Please sign in to comment.