Skip to content
This repository was archived by the owner on Aug 24, 2024. It is now read-only.

performance, reliability, features #44

Merged
merged 19 commits into from
Mar 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions custom_components/jvc_projectors/__init__.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
"""The JVC Projector integration."""

from __future__ import annotations
from jvc_projector.jvc_projector import JVCProjectorCoordinator, JVCInput
import logging
import asyncio
from jvc_projector.jvc_projector import JVCProjectorCoordinator, JVCInput
from homeassistant import config_entries
from homeassistant.const import (
CONF_HOST,
CONF_NAME,
CONF_PASSWORD,
CONF_TIMEOUT,
CONF_SCAN_INTERVAL,
Platform,
)
from homeassistant.config_entries import ConfigEntry
Expand All @@ -28,19 +25,9 @@ async def async_setup_entry(hass, entry):

timeout = entry.data.get(CONF_TIMEOUT, 3)
port = 20554
_LOGGER.debug(f"Setting up JVC Projector with host: {host}")
options = JVCInput(host, password, port, timeout)
# Create a coordinator or directly set up your entities with the provided information
coordinator = JVCProjectorCoordinator(options, _LOGGER)
# I dont want to open a connection unless its on because then I can't test
# try:
# res = await coordinator.open_connection()
# if not res:
# _LOGGER.error("Error setting up JVC Projector during async_setup_entry")
# return False
# except Exception as e:
# _LOGGER.error("Error setting up JVC Projector during async_setup_entry - %s", e)
# return False

# Store the coordinator in hass.data for use by your platform (e.g., remote)
hass.data[DOMAIN] = coordinator
Expand Down
27 changes: 13 additions & 14 deletions custom_components/jvc_projectors/config_flow.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import voluptuous as vol
import logging
from homeassistant import config_entries, core
from homeassistant import config_entries
from homeassistant.core import callback
from homeassistant.const import (
CONF_HOST,
CONF_NAME,
CONF_PASSWORD,
CONF_TIMEOUT,
CONF_SCAN_INTERVAL,
CONF_PASSWORD
)
import homeassistant.helpers.config_validation as cv
from jvc_projector.jvc_projector import JVCProjectorCoordinator, JVCInput

from .const import DOMAIN # Import the domain constant
Expand All @@ -29,7 +26,7 @@ async def async_step_user(self, user_input=None):
if user_input is not None:
host = user_input.get(CONF_HOST)
password = user_input.get(CONF_PASSWORD)
timeout = user_input.get(CONF_TIMEOUT, 3)
timeout = 5

valid = await self.validate_setup(host, password, timeout)

Expand All @@ -46,8 +43,7 @@ async def async_step_user(self, user_input=None):
{
vol.Required(CONF_NAME): str,
vol.Required(CONF_HOST): str,
vol.Optional(CONF_PASSWORD): str,
vol.Optional(CONF_TIMEOUT, default=3): int,
vol.Optional(CONF_PASSWORD): str
}
)

Expand All @@ -59,13 +55,19 @@ async def validate_setup(self, host: str, password: str, timeout: int) -> bool:
"""return True if the projector connects"""
try:
options = JVCInput(host, password, 20554, timeout)
coordinator = JVCProjectorCoordinator(options)
coordinator = JVCProjectorCoordinator(options, _LOGGER)
_LOGGER.debug("Validating JVC Projector setup")
res = await coordinator.open_connection()
if res:
_LOGGER.debug("JVC Projector setup connection worked")
await coordinator.close_connection()
_LOGGER.debug("JVC Projector setup connection sucessfully closed")
return True
except Exception as e:
_LOGGER.error("Error validating JVC Projector setup: %s", e)
_LOGGER.error(
"Error validating JVC Projector setup. Please check host and password: %s",
e,
)
return False
return False

Expand Down Expand Up @@ -109,10 +111,7 @@ async def async_step_init(self, user_input=None):
vol.Optional(CONF_HOST, default=current_config.get(CONF_HOST)): str,
vol.Optional(
CONF_PASSWORD, default=current_config.get(CONF_PASSWORD)
): str,
vol.Optional(
CONF_TIMEOUT, default=current_config.get(CONF_TIMEOUT, 3)
): int,
): str
}
)

Expand Down
3 changes: 2 additions & 1 deletion custom_components/jvc_projectors/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
"config_flow": true,
"documentation": "https://github.com/iloveicedgreentea/jvc_homeassistant",
"requirements": [
"pyjvc==4.2.1"
"pyjvc==4.3.51"
],
"ssdp": [],
"zeroconf": [],
"homekit": {},
"dependencies": [],
"loggers": ["custom_components.jvc_projectors"],
"codeowners": [
"@iloveicedgreentea"
],
Expand Down
Loading