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 .const import DOMAIN
|
||||
from redgtech_api import RedgtechAPI
|
||||
from typing import TypedDict
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
class RedgtechEntryData(TypedDict):
|
||||
config: dict
|
||||
entities: list
|
||||
|
||||
PLATFORMS: list[Platform] = [Platform.SWITCH]
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
|
@ -1,37 +1,43 @@
|
||||
from homeassistant import config_entries
|
||||
import voluptuous as vol
|
||||
import logging
|
||||
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD, CONF_ACCESS_TOKEN
|
||||
from .const import DOMAIN
|
||||
from redgtech_api import RedgtechAPI
|
||||
from typing import Any, Dict, Optional
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
class RedgtechConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
"""Config Flow for Redgtech integration."""
|
||||
|
||||
VERSION = 1
|
||||
|
||||
async def async_step_user(self, user_input=None):
|
||||
async def async_step_user(self, user_input: Optional[Dict[str, Any]] = None) -> config_entries.FlowResult:
|
||||
"""Handle the initial user step for login."""
|
||||
errors = {}
|
||||
|
||||
if user_input is not None:
|
||||
email = user_input.get("email")
|
||||
password = user_input.get("password")
|
||||
|
||||
email = user_input.get(CONF_EMAIL)
|
||||
password = user_input.get(CONF_PASSWORD)
|
||||
api = RedgtechAPI()
|
||||
|
||||
try:
|
||||
access_token = await api.login(email, password)
|
||||
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(
|
||||
title="Redgtech",
|
||||
data={"access_token": access_token}
|
||||
data={CONF_ACCESS_TOKEN: access_token}
|
||||
)
|
||||
else:
|
||||
|
||||
_LOGGER.error("Login failed: No access token received")
|
||||
errors["base"] = "invalid_auth"
|
||||
|
||||
except Exception as e:
|
||||
_LOGGER.error("Login failed: %s", e)
|
||||
errors["base"] = "cannot_connect"
|
||||
@ -39,8 +45,8 @@ class RedgtechConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
return self.async_show_form(
|
||||
step_id="user",
|
||||
data_schema=vol.Schema({
|
||||
vol.Required("email"): str,
|
||||
vol.Required("password"): str,
|
||||
vol.Required(CONF_EMAIL): str,
|
||||
vol.Required(CONF_PASSWORD): str,
|
||||
}),
|
||||
errors=errors
|
||||
)
|
@ -1,12 +1,11 @@
|
||||
{
|
||||
"domain": "redgtech",
|
||||
"name": "Redgtech",
|
||||
"codeowners": [],
|
||||
"codeowners": ["@jonhsady", "@luan-nvg"],
|
||||
"documentation": "https://www.home-assistant.io/integrations/redgtech",
|
||||
"iot_class": "cloud_polling",
|
||||
"logo": "/brands/redgtech/logo.png",
|
||||
"integration_type": "service",
|
||||
"config_flow": true,
|
||||
"quality_scale": "silver",
|
||||
"requirements": ["redgtech-api==0.1.14"]
|
||||
"quality_scale": "bronze",
|
||||
"requirements": ["redgtech-api==0.1.16"]
|
||||
}
|
@ -3,13 +3,9 @@ rules:
|
||||
action-setup:
|
||||
status: exempt
|
||||
comment: only entity actions
|
||||
appropriate-polling:
|
||||
status: exempt
|
||||
comment: the integration does not poll
|
||||
appropriate-polling: done
|
||||
brands: done
|
||||
common-modules:
|
||||
status: exempt
|
||||
comment: the integration currently implements only one platform and has no coordinator
|
||||
common-modules: done
|
||||
config-flow-test-coverage: done
|
||||
config-flow: done
|
||||
dependency-transparency: done
|
||||
@ -17,9 +13,7 @@ rules:
|
||||
docs-high-level-description: done
|
||||
docs-installation-instructions: done
|
||||
docs-removal-instructions: done
|
||||
entity-event-setup:
|
||||
status: exempt
|
||||
comment: the integration does not subscribe to events
|
||||
entity-event-setup: done
|
||||
entity-unique-id: done
|
||||
has-entity-name: done
|
||||
runtime-data: done
|
||||
|
@ -5,63 +5,23 @@
|
||||
"title": "User Configuration",
|
||||
"description": "Please enter your email address.",
|
||||
"data": {
|
||||
"email": "Email",
|
||||
"password": "Password"
|
||||
"email": {
|
||||
"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 = []
|
||||
if coordinator.data:
|
||||
existing_entities = hass.data.get(DOMAIN, {}).get("entities", [])
|
||||
for item in coordinator.data.get("boards", []):
|
||||
entity_id = item.get("endpointId", "")
|
||||
if entity_id not in existing_entities:
|
||||
categories = item.get("displayCategories", "")
|
||||
if "SWITCH" in categories:
|
||||
entities.append(RedgtechSwitch(coordinator, item, api))
|
||||
existing_entities.append(entity_id)
|
||||
|
||||
hass.data.setdefault(DOMAIN, {})["entities"] = existing_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
|
||||
|
||||
# homeassistant.components.redgtech
|
||||
redgtech-api==0.1.14
|
||||
redgtech-api==0.1.16
|
||||
|
||||
# homeassistant.components.refoss
|
||||
refoss-ha==1.2.5
|
||||
|
Loading…
x
Reference in New Issue
Block a user