mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
adjustments for colaborator
This commit is contained in:
parent
14c8a01f96
commit
3ed71412d4
@ -4,9 +4,14 @@ from homeassistant.config_entries import ConfigEntry
|
|||||||
from homeassistant.const import Platform
|
from homeassistant.const import Platform
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from redgtech_api import RedgtechAPI
|
from redgtech_api import RedgtechAPI
|
||||||
|
from typing import TypedDict
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
class RedgtechEntryData(TypedDict):
|
||||||
|
config: dict
|
||||||
|
entities: list
|
||||||
|
|
||||||
PLATFORMS: list[Platform] = [Platform.SWITCH]
|
PLATFORMS: list[Platform] = [Platform.SWITCH]
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
|
@ -1,37 +1,43 @@
|
|||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
import logging
|
import logging
|
||||||
|
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD, CONF_ACCESS_TOKEN
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from redgtech_api import RedgtechAPI
|
from redgtech_api import RedgtechAPI
|
||||||
|
from typing import Any, Dict, Optional
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
class RedgtechConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class RedgtechConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
"""Config Flow for Redgtech integration."""
|
"""Config Flow for Redgtech integration."""
|
||||||
|
|
||||||
VERSION = 1
|
async def async_step_user(self, user_input: Optional[Dict[str, Any]] = None) -> config_entries.FlowResult:
|
||||||
|
|
||||||
async def async_step_user(self, user_input=None):
|
|
||||||
"""Handle the initial user step for login."""
|
"""Handle the initial user step for login."""
|
||||||
errors = {}
|
errors = {}
|
||||||
|
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
email = user_input.get("email")
|
email = user_input.get(CONF_EMAIL)
|
||||||
password = user_input.get("password")
|
password = user_input.get(CONF_PASSWORD)
|
||||||
|
|
||||||
api = RedgtechAPI()
|
api = RedgtechAPI()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
access_token = await api.login(email, password)
|
access_token = await api.login(email, password)
|
||||||
if access_token:
|
if access_token:
|
||||||
_LOGGER.info("Login successful")
|
_LOGGER.debug("Login successful, token received.")
|
||||||
|
|
||||||
|
existing_entries = self._async_current_entries()
|
||||||
|
for entry in existing_entries:
|
||||||
|
if entry.data.get(CONF_ACCESS_TOKEN) == access_token:
|
||||||
|
return self.async_abort(reason="already_configured")
|
||||||
|
|
||||||
return self.async_create_entry(
|
return self.async_create_entry(
|
||||||
title="Redgtech",
|
title="Redgtech",
|
||||||
data={"access_token": access_token}
|
data={CONF_ACCESS_TOKEN: access_token}
|
||||||
)
|
)
|
||||||
else:
|
|
||||||
_LOGGER.error("Login failed: No access token received")
|
_LOGGER.error("Login failed: No access token received")
|
||||||
errors["base"] = "invalid_auth"
|
errors["base"] = "invalid_auth"
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
_LOGGER.error("Login failed: %s", e)
|
_LOGGER.error("Login failed: %s", e)
|
||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
@ -39,8 +45,8 @@ class RedgtechConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
step_id="user",
|
step_id="user",
|
||||||
data_schema=vol.Schema({
|
data_schema=vol.Schema({
|
||||||
vol.Required("email"): str,
|
vol.Required(CONF_EMAIL): str,
|
||||||
vol.Required("password"): str,
|
vol.Required(CONF_PASSWORD): str,
|
||||||
}),
|
}),
|
||||||
errors=errors
|
errors=errors
|
||||||
)
|
)
|
@ -1,12 +1,11 @@
|
|||||||
{
|
{
|
||||||
"domain": "redgtech",
|
"domain": "redgtech",
|
||||||
"name": "Redgtech",
|
"name": "Redgtech",
|
||||||
"codeowners": [],
|
"codeowners": ["@jonhsady", "@luan-nvg"],
|
||||||
"documentation": "https://www.home-assistant.io/integrations/redgtech",
|
"documentation": "https://www.home-assistant.io/integrations/redgtech",
|
||||||
"iot_class": "cloud_polling",
|
"iot_class": "cloud_polling",
|
||||||
"logo": "/brands/redgtech/logo.png",
|
|
||||||
"integration_type": "service",
|
"integration_type": "service",
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"quality_scale": "silver",
|
"quality_scale": "bronze",
|
||||||
"requirements": ["redgtech-api==0.1.14"]
|
"requirements": ["redgtech-api==0.1.16"]
|
||||||
}
|
}
|
@ -3,13 +3,9 @@ rules:
|
|||||||
action-setup:
|
action-setup:
|
||||||
status: exempt
|
status: exempt
|
||||||
comment: only entity actions
|
comment: only entity actions
|
||||||
appropriate-polling:
|
appropriate-polling: done
|
||||||
status: exempt
|
|
||||||
comment: the integration does not poll
|
|
||||||
brands: done
|
brands: done
|
||||||
common-modules:
|
common-modules: done
|
||||||
status: exempt
|
|
||||||
comment: the integration currently implements only one platform and has no coordinator
|
|
||||||
config-flow-test-coverage: done
|
config-flow-test-coverage: done
|
||||||
config-flow: done
|
config-flow: done
|
||||||
dependency-transparency: done
|
dependency-transparency: done
|
||||||
@ -17,9 +13,7 @@ rules:
|
|||||||
docs-high-level-description: done
|
docs-high-level-description: done
|
||||||
docs-installation-instructions: done
|
docs-installation-instructions: done
|
||||||
docs-removal-instructions: done
|
docs-removal-instructions: done
|
||||||
entity-event-setup:
|
entity-event-setup: done
|
||||||
status: exempt
|
|
||||||
comment: the integration does not subscribe to events
|
|
||||||
entity-unique-id: done
|
entity-unique-id: done
|
||||||
has-entity-name: done
|
has-entity-name: done
|
||||||
runtime-data: done
|
runtime-data: done
|
||||||
|
@ -5,63 +5,23 @@
|
|||||||
"title": "User Configuration",
|
"title": "User Configuration",
|
||||||
"description": "Please enter your email address.",
|
"description": "Please enter your email address.",
|
||||||
"data": {
|
"data": {
|
||||||
"email": "Email",
|
"email": {
|
||||||
"password": "Password"
|
"label": "Email",
|
||||||
|
"description": "Enter your email address for authentication."
|
||||||
|
},
|
||||||
|
"password": {
|
||||||
|
"label": "Password",
|
||||||
|
"description": "Enter your password for authentication."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"errors": {
|
||||||
|
"invalid_auth": "Invalid authentication.",
|
||||||
|
"invalid_email": "Invalid email address.",
|
||||||
|
"invalid_password": "Invalid password.",
|
||||||
|
"email_required": "Email is required.",
|
||||||
|
"password_required": "Password is required."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"common": {
|
|
||||||
"generic": {
|
|
||||||
"model": "Model",
|
|
||||||
"ui_managed": "Managed via UI"
|
|
||||||
},
|
|
||||||
"device_automation": {
|
|
||||||
"condition_type": {
|
|
||||||
"is_on": "{entity_name} is on",
|
|
||||||
"is_off": "{entity_name} is off"
|
|
||||||
},
|
|
||||||
"extra_fields": {
|
|
||||||
"above": "Above",
|
|
||||||
"below": "Below",
|
|
||||||
"for": "Duration",
|
|
||||||
"to": "To",
|
|
||||||
"value": "Value",
|
|
||||||
"zone": "Zone"
|
|
||||||
},
|
|
||||||
"trigger_type": {
|
|
||||||
"changed_states": "{entity_name} turned on or off",
|
|
||||||
"turned_on": "{entity_name} turned on",
|
|
||||||
"turned_off": "{entity_name} turned off"
|
|
||||||
},
|
|
||||||
"action_type": {
|
|
||||||
"toggle": "Toggle {entity_name}",
|
|
||||||
"turn_on": "Turn on {entity_name}",
|
|
||||||
"turn_off": "Turn off {entity_name}"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"action": {
|
|
||||||
"connect": "Connect",
|
|
||||||
"disconnect": "Disconnect",
|
|
||||||
"enable": "Enable",
|
|
||||||
"disable": "Disable",
|
|
||||||
"open": "Open",
|
|
||||||
"close": "Close",
|
|
||||||
"reload": "Reload",
|
|
||||||
"restart": "Restart",
|
|
||||||
"start": "Start",
|
|
||||||
"stop": "Stop",
|
|
||||||
"pause": "Pause",
|
|
||||||
"turn_on": "Turn on",
|
|
||||||
"turn_off": "Turn off",
|
|
||||||
"toggle": "Toggle"
|
|
||||||
},
|
|
||||||
"time": {
|
|
||||||
"sunday": "Sunday"
|
|
||||||
},
|
|
||||||
"state": {
|
|
||||||
"not_home": "Away"
|
|
||||||
},
|
|
||||||
"config_flow": {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
@ -20,10 +20,16 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||||||
|
|
||||||
entities = []
|
entities = []
|
||||||
if coordinator.data:
|
if coordinator.data:
|
||||||
|
existing_entities = hass.data.get(DOMAIN, {}).get("entities", [])
|
||||||
for item in coordinator.data.get("boards", []):
|
for item in coordinator.data.get("boards", []):
|
||||||
|
entity_id = item.get("endpointId", "")
|
||||||
|
if entity_id not in existing_entities:
|
||||||
categories = item.get("displayCategories", "")
|
categories = item.get("displayCategories", "")
|
||||||
if "SWITCH" in categories:
|
if "SWITCH" in categories:
|
||||||
entities.append(RedgtechSwitch(coordinator, item, api))
|
entities.append(RedgtechSwitch(coordinator, item, api))
|
||||||
|
existing_entities.append(entity_id)
|
||||||
|
|
||||||
|
hass.data.setdefault(DOMAIN, {})["entities"] = existing_entities
|
||||||
|
|
||||||
async_add_entities(entities)
|
async_add_entities(entities)
|
||||||
|
|
||||||
|
2
requirements_all.txt
generated
2
requirements_all.txt
generated
@ -2603,7 +2603,7 @@ rapt-ble==0.1.2
|
|||||||
raspyrfm-client==1.2.8
|
raspyrfm-client==1.2.8
|
||||||
|
|
||||||
# homeassistant.components.redgtech
|
# homeassistant.components.redgtech
|
||||||
redgtech-api==0.1.14
|
redgtech-api==0.1.16
|
||||||
|
|
||||||
# homeassistant.components.refoss
|
# homeassistant.components.refoss
|
||||||
refoss-ha==1.2.5
|
refoss-ha==1.2.5
|
||||||
|
Loading…
x
Reference in New Issue
Block a user