-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Limit options to title, favicon, apple. Add gui configuration!
- Loading branch information
1 parent
09da46f
commit 41345d3
Showing
6 changed files
with
160 additions
and
66 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
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,30 @@ | ||
{ | ||
"config": { | ||
"title": "Favicon", | ||
"step": { | ||
"config": { | ||
"title": "Favicon changer", | ||
"description": "Set the page title, favicon and/or iOS icons", | ||
"data": { | ||
"title": "Page title", | ||
"favicon": "favicon URL", | ||
"apple": "iOS icon URL" | ||
} | ||
} | ||
}, | ||
"abort": { | ||
"single_instance_allowed": "Only a single configuration of favicon is allowed." | ||
} | ||
}, | ||
"options": { | ||
"step": { | ||
"init": { | ||
"data": { | ||
"title": "Page title", | ||
"favicon": "favicon URL", | ||
"apple": "iOS icon URL" | ||
} | ||
} | ||
} | ||
} | ||
} |
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
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,55 @@ | ||
import voluptuous as vol | ||
|
||
from homeassistant import config_entries | ||
from homeassistant.core import callback | ||
|
||
@config_entries.HANDLERS.register("favicon") | ||
class ExampleConfigFlow(config_entries.ConfigFlow): | ||
async def async_step_user(self, user_input=None): | ||
if self._async_current_entries(): | ||
return self.async_abort(reason="single_instance_allowed") | ||
return await self.async_step_config() | ||
|
||
async def async_step_config(self, user_input=None): | ||
if user_input is not None: | ||
return self.async_create_entry( | ||
title="", data=user_input) | ||
|
||
return self.async_show_form( | ||
step_id='config', | ||
data_schema=vol.Schema( | ||
{ | ||
vol.Optional('title'): str, | ||
vol.Optional('favicon'): str, | ||
vol.Optional('apple'): str, | ||
} | ||
), | ||
) | ||
|
||
@staticmethod | ||
@callback | ||
def async_get_options_flow(config_entry): | ||
return ExampleEditFlow(config_entry) | ||
|
||
class ExampleEditFlow(config_entries.OptionsFlow): | ||
|
||
def __init__(self, config_entry): | ||
self.config_entry = config_entry | ||
|
||
async def async_step_init(self, user_input=None): | ||
if user_input is not None: | ||
return self.async_create_entry(title="", data=user_input) | ||
return self.async_show_form( | ||
step_id='init', | ||
data_schema=vol.Schema( | ||
{ | ||
vol.Optional('title', | ||
default=self.config_entry.options.get("title", "")): str, | ||
vol.Optional('favicon', | ||
default=self.config_entry.options.get("favicon", "")): str, | ||
vol.Optional('apple', | ||
default=self.config_entry.options.get("apple", "")): str, | ||
} | ||
), | ||
) | ||
|
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
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