Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
HomeAssistant
Core
Commits
28e68eaa
Unverified
Commit
28e68eaa
authored
4 years ago
by
Chris Talkington
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Reload sonarr config entry on options update (#41958)
parent
b04837e9
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
homeassistant/components/sonarr/__init__.py
+1
-4
1 addition, 4 deletions
homeassistant/components/sonarr/__init__.py
homeassistant/components/sonarr/sensor.py
+0
-33
0 additions, 33 deletions
homeassistant/components/sonarr/sensor.py
with
1 addition
and
37 deletions
homeassistant/components/sonarr/__init__.py
+
1
−
4
View file @
28e68eaa
...
...
@@ -18,7 +18,6 @@ from homeassistant.const import (
)
from
homeassistant.exceptions
import
ConfigEntryNotReady
from
homeassistant.helpers.aiohttp_client
import
async_get_clientsession
from
homeassistant.helpers.dispatcher
import
async_dispatcher_send
from
homeassistant.helpers.entity
import
Entity
from
homeassistant.helpers.typing
import
HomeAssistantType
...
...
@@ -125,9 +124,7 @@ def _async_start_reauth(hass: HomeAssistantType, entry: ConfigEntry):
async
def
_async_update_listener
(
hass
:
HomeAssistantType
,
entry
:
ConfigEntry
)
->
None
:
"""
Handle options update.
"""
async_dispatcher_send
(
hass
,
f
"
sonarr.
{
entry
.
entry_id
}
.entry_options_update
"
,
entry
.
options
)
await
hass
.
config_entries
.
async_reload
(
entry
.
entry_id
)
class
SonarrEntity
(
Entity
):
...
...
This diff is collapsed.
Click to expand it.
homeassistant/components/sonarr/sensor.py
+
0
−
33
View file @
28e68eaa
...
...
@@ -7,7 +7,6 @@ from sonarr import Sonarr, SonarrConnectionError, SonarrError
from
homeassistant.config_entries
import
ConfigEntry
from
homeassistant.const
import
DATA_GIGABYTES
from
homeassistant.helpers.dispatcher
import
async_dispatcher_connect
from
homeassistant.helpers.entity
import
Entity
from
homeassistant.helpers.typing
import
HomeAssistantType
import
homeassistant.util.dt
as
dt_util
...
...
@@ -291,18 +290,6 @@ class SonarrUpcomingSensor(SonarrSensor):
unit_of_measurement
=
"
Episodes
"
,
)
async
def
async_added_to_hass
(
self
):
"""
Listen for signals.
"""
await
super
().
async_added_to_hass
()
self
.
async_on_remove
(
async_dispatcher_connect
(
self
.
hass
,
f
"
sonarr.
{
self
.
_entry_id
}
.entry_options_update
"
,
self
.
async_update_entry_options
,
)
)
@sonarr_exception_handler
async
def
async_update
(
self
)
->
None
:
"""
Update entity.
"""
...
...
@@ -313,10 +300,6 @@ class SonarrUpcomingSensor(SonarrSensor):
start
=
start
.
isoformat
(),
end
=
end
.
isoformat
()
)
async
def
async_update_entry_options
(
self
,
options
:
dict
)
->
None
:
"""
Update sensor settings when config entry options are update.
"""
self
.
_days
=
options
[
CONF_UPCOMING_DAYS
]
@property
def
device_state_attributes
(
self
)
->
Optional
[
Dict
[
str
,
Any
]]:
"""
Return the state attributes of the entity.
"""
...
...
@@ -352,28 +335,12 @@ class SonarrWantedSensor(SonarrSensor):
enabled_default
=
False
,
)
async
def
async_added_to_hass
(
self
):
"""
Listen for signals.
"""
await
super
().
async_added_to_hass
()
self
.
async_on_remove
(
async_dispatcher_connect
(
self
.
hass
,
f
"
sonarr.
{
self
.
_entry_id
}
.entry_options_update
"
,
self
.
async_update_entry_options
,
)
)
@sonarr_exception_handler
async
def
async_update
(
self
)
->
None
:
"""
Update entity.
"""
self
.
_results
=
await
self
.
sonarr
.
wanted
(
page_size
=
self
.
_max_items
)
self
.
_total
=
self
.
_results
.
total
async
def
async_update_entry_options
(
self
,
options
:
dict
)
->
None
:
"""
Update sensor settings when config entry options are update.
"""
self
.
_max_items
=
options
[
CONF_WANTED_MAX_ITEMS
]
@property
def
device_state_attributes
(
self
)
->
Optional
[
Dict
[
str
,
Any
]]:
"""
Return the state attributes of the entity.
"""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment