-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
DeveloperSteve
authored and
DeveloperSteve
committed
Nov 19, 2023
1 parent
5b2a82e
commit d63a32c
Showing
2 changed files
with
82 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import voluptuous as vol | ||
from homeassistant import config_entries | ||
from homeassistant.const import CONF_PASSWORD | ||
|
||
# Define the schema for the Cumulocity IoT configuration. | ||
CONFIG_SCHEMA = vol.Schema({ | ||
vol.Required("base_url"): str, | ||
vol.Required("tenant"): str, | ||
vol.Required("username"): str, | ||
vol.Required(CONF_PASSWORD): str, | ||
}) | ||
|
||
class CumulocityConfigFlow(config_entries.ConfigFlow, domain="cumulocity"): | ||
"""Cumulocity IoT Configuration Flow.""" | ||
|
||
async def async_step_user(self, user_input=None): | ||
"""Handle the initial step.""" | ||
if user_input is not None: | ||
# Store the configuration data in the options entry. | ||
title = "Cumulocity IoT" | ||
data = user_input | ||
return self.async_create_entry(title=title, data=data) | ||
|
||
return self.show_form() | ||
|
||
async def show_form(self, errors=None): | ||
"""Show the configuration form to the user.""" | ||
return self.async_show_form( | ||
step_id="user", | ||
data_schema=vol.Schema(CONFIG_SCHEMA), | ||
errors=errors or {}, | ||
) | ||
|
||
async def async_step_config_entry(self, config_entry): | ||
"""Handle the configuration entry options.""" | ||
if config_entry.source == config_entries.SOURCE_IMPORT: | ||
return self.async_abort(reason="Configuration via YAML not supported.") | ||
|
||
if self.source == config_entries.SOURCE_REAUTH: | ||
# Reauth is not supported. | ||
return self.async_abort(reason="Reauthentication is not supported.") | ||
|
||
# Configure the options flow for additional settings, including password. | ||
return await self.async_step_options() | ||
|
||
async def async_step_options(self, user_input=None): | ||
"""Handle the options flow.""" | ||
if user_input is not None: | ||
# Update the options with the user's input. | ||
self.hass.config_entries.async_update_entry( | ||
self.config_entry, | ||
options=user_input, | ||
) | ||
return self.async_create_entry(title="", data={}) | ||
|
||
return self.async_show_form( | ||
step_id="options", | ||
data_schema=vol.Schema(CONFIG_SCHEMA), | ||
description_placeholders={"title": self.config_entry.title}, | ||
) | ||
|
||
async def async_step_remove(self, user_input=None): | ||
"""Handle removal of the entry.""" | ||
if user_input is not None: | ||
return await self.async_remove_entry(entry=self.config_entry) | ||
|
||
return self.async_show_form(step_id="remove_confirm") | ||
|
||
# Example YAML configuration for the configuration.yaml file. | ||
# cumulocity: | ||
# base_url: "https://your-cumulocity-instance.com" | ||
# tenant: "your-tenant-id" | ||
# username: "your-username" | ||
# password: "your-password" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
{ | ||
"domain": "integration-hacs", | ||
"name": "integration-hacs", | ||
"documentation": "https://github.com/ludeeus/integration-hacs", | ||
"domain": "cumulocity-hacs", | ||
"name": "cumulocity hacs integration", | ||
"documentation": "https://github.com/thecoochins/integration-hacs", | ||
"dependencies": [], | ||
"codeowners": ["@ludeeus"], | ||
"codeowners": ["@developersteve", "@quinnfenpen"], | ||
"requirements": [], | ||
"homeassistant": "0.95.0" | ||
} | ||
"homeassistant": "0.95.0", | ||
"config_flow": true | ||
} | ||
|