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
c584b6b2
Commit
c584b6b2
authored
9 years ago
by
John Arild Berentsen
Browse files
Options
Downloads
Patches
Plain Diff
Support for Mousedetectors connected in Verisure systems
parent
4ce1a67c
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/sensor/verisure.py
+38
-0
38 additions, 0 deletions
homeassistant/components/sensor/verisure.py
homeassistant/components/verisure.py
+15
-2
15 additions, 2 deletions
homeassistant/components/verisure.py
with
53 additions
and
2 deletions
homeassistant/components/sensor/verisure.py
+
38
−
0
View file @
c584b6b2
...
...
@@ -39,6 +39,13 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
hasattr
(
value
,
'
humidity
'
)
and
value
.
humidity
])
sensors
.
extend
([
VerisureMouseDetection
(
value
)
for
value
in
verisure
.
MOUSEDETECTION_STATUS
.
values
()
if
verisure
.
SHOW_MOUSEDETECTION
and
hasattr
(
value
,
'
amountText
'
)
and
value
.
amountText
])
add_devices
(
sensors
)
...
...
@@ -98,3 +105,34 @@ class VerisureHygrometer(Entity):
def
update
(
self
):
"""
update sensor
"""
verisure
.
update_climate
()
class
VerisureMouseDetection
(
Entity
):
"""
represents a Verisure mousedetector within home assistant.
"""
def
__init__
(
self
,
mousedetection_status
):
self
.
_id
=
mousedetection_status
.
deviceLabel
@property
def
name
(
self
):
"""
Returns the name of the device.
"""
return
'
{} {}
'
.
format
(
verisure
.
MOUSEDETECTION_STATUS
[
self
.
_id
].
location
,
"
Mouse
"
)
@property
def
state
(
self
):
"""
Returns the state of the device.
"""
return
verisure
.
MOUSEDETECTION_STATUS
[
self
.
_id
].
count
@property
def
unit_of_measurement
(
self
):
"""
Unit of measurement of this entity
"""
if
verisure
.
MOUSEDETECTION_STATUS
[
self
.
_id
].
count
>=
1
:
return
"
Mice
"
else
:
return
"
Mouse
"
def
update
(
self
):
"""
update sensor
"""
verisure
.
update_mousedetection
()
This diff is collapsed.
Click to expand it.
homeassistant/components/verisure.py
+
15
−
2
View file @
c584b6b2
...
...
@@ -38,6 +38,7 @@ ALARM_STATUS = {}
SMARTPLUG_STATUS
=
{}
CLIMATE_STATUS
=
{}
LOCK_STATUS
=
{}
MOUSEDETECTION_STATUS
=
{}
VERISURE_LOGIN_ERROR
=
None
VERISURE_ERROR
=
None
...
...
@@ -47,6 +48,7 @@ SHOW_HYGROMETERS = True
SHOW_ALARM
=
True
SHOW_SMARTPLUGS
=
True
SHOW_LOCKS
=
True
SHOW_MOUSEDETECTION
=
True
CODE_DIGITS
=
4
# if wrong password was given don't try again
...
...
@@ -66,12 +68,14 @@ def setup(hass, config):
from
verisure
import
MyPages
,
LoginError
,
Error
global
SHOW_THERMOMETERS
,
SHOW_HYGROMETERS
,
\
SHOW_ALARM
,
SHOW_SMARTPLUGS
,
SHOW_LOCKS
,
CODE_DIGITS
SHOW_ALARM
,
SHOW_SMARTPLUGS
,
SHOW_LOCKS
,
SHOW_MOUSEDETECTION
,
\
CODE_DIGITS
SHOW_THERMOMETERS
=
int
(
config
[
DOMAIN
].
get
(
'
thermometers
'
,
'
1
'
))
SHOW_HYGROMETERS
=
int
(
config
[
DOMAIN
].
get
(
'
hygrometers
'
,
'
1
'
))
SHOW_ALARM
=
int
(
config
[
DOMAIN
].
get
(
'
alarm
'
,
'
1
'
))
SHOW_SMARTPLUGS
=
int
(
config
[
DOMAIN
].
get
(
'
smartplugs
'
,
'
1
'
))
SHOW_LOCKS
=
int
(
config
[
DOMAIN
].
get
(
'
locks
'
,
'
1
'
))
SHOW_MOUSEDETECTION
=
int
(
config
[
DOMAIN
].
get
(
'
mouse
'
,
'
1
'
))
CODE_DIGITS
=
int
(
config
[
DOMAIN
].
get
(
'
code_digits
'
,
'
4
'
))
global
MY_PAGES
...
...
@@ -92,6 +96,7 @@ def setup(hass, config):
update_climate
()
update_smartplug
()
update_lock
()
update_mousedetection
()
# Load components for the devices in the ISY controller that we support
for
comp_name
,
discovery
in
(((
'
sensor
'
,
DISCOVER_SENSORS
),
...
...
@@ -145,6 +150,11 @@ def update_lock():
update_component
(
MY_PAGES
.
lock
.
get
,
LOCK_STATUS
)
def
update_mousedetection
():
"""
Updates the status of mouse detectors.
"""
update_component
(
MY_PAGES
.
mousedetection
.
get
,
MOUSEDETECTION_STATUS
)
def
update_component
(
get_function
,
status
):
"""
Updates the status of verisure components.
"""
if
WRONG_PASSWORD_GIVEN
:
...
...
@@ -152,7 +162,10 @@ def update_component(get_function, status):
return
try
:
for
overview
in
get_function
():
status
[
overview
.
id
]
=
overview
try
:
status
[
overview
.
id
]
=
overview
except
IndexError
:
status
[
overview
.
deviceLabel
]
=
overview
except
(
ConnectionError
,
VERISURE_ERROR
)
as
ex
:
_LOGGER
.
error
(
'
Caught connection error %s, tries to reconnect
'
,
ex
)
reconnect
()
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