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
6834e00b
Commit
6834e00b
authored
6 years ago
by
fucm
Committed by
Paulus Schoutsen
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add support for Tahoma Soke Sensor (#15441)
parent
26375a30
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/binary_sensor/tahoma.py
+98
-0
98 additions, 0 deletions
homeassistant/components/binary_sensor/tahoma.py
homeassistant/components/tahoma.py
+2
-1
2 additions, 1 deletion
homeassistant/components/tahoma.py
with
100 additions
and
1 deletion
homeassistant/components/binary_sensor/tahoma.py
0 → 100644
+
98
−
0
View file @
6834e00b
"""
Support for Tahoma binary sensors.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/binary_sensor.tahoma/
"""
import
logging
from
datetime
import
timedelta
from
homeassistant.components.binary_sensor
import
(
BinarySensorDevice
)
from
homeassistant.components.tahoma
import
(
DOMAIN
as
TAHOMA_DOMAIN
,
TahomaDevice
)
from
homeassistant.const
import
(
STATE_OFF
,
STATE_ON
,
ATTR_BATTERY_LEVEL
)
DEPENDENCIES
=
[
'
tahoma
'
]
_LOGGER
=
logging
.
getLogger
(
__name__
)
SCAN_INTERVAL
=
timedelta
(
seconds
=
120
)
def
setup_platform
(
hass
,
config
,
add_devices
,
discovery_info
=
None
):
"""
Set up Tahoma controller devices.
"""
_LOGGER
.
debug
(
"
Setup Tahoma Binary sensor platform
"
)
controller
=
hass
.
data
[
TAHOMA_DOMAIN
][
'
controller
'
]
devices
=
[]
for
device
in
hass
.
data
[
TAHOMA_DOMAIN
][
'
devices
'
][
'
smoke
'
]:
devices
.
append
(
TahomaBinarySensor
(
device
,
controller
))
add_devices
(
devices
,
True
)
class
TahomaBinarySensor
(
TahomaDevice
,
BinarySensorDevice
):
"""
Representation of a Tahoma Binary Sensor.
"""
def
__init__
(
self
,
tahoma_device
,
controller
):
"""
Initialize the sensor.
"""
super
().
__init__
(
tahoma_device
,
controller
)
self
.
_state
=
None
self
.
_icon
=
None
self
.
_battery
=
None
@property
def
is_on
(
self
):
"""
Return the state of the sensor.
"""
return
bool
(
self
.
_state
==
STATE_ON
)
@property
def
device_class
(
self
):
"""
Return the class of the device.
"""
if
self
.
tahoma_device
.
type
==
'
rtds:RTDSSmokeSensor
'
:
return
'
smoke
'
return
None
@property
def
icon
(
self
):
"""
Icon for device by its type.
"""
return
self
.
_icon
@property
def
device_state_attributes
(
self
):
"""
Return the device state attributes.
"""
attr
=
{}
super_attr
=
super
().
device_state_attributes
if
super_attr
is
not
None
:
attr
.
update
(
super_attr
)
if
self
.
_battery
is
not
None
:
attr
[
ATTR_BATTERY_LEVEL
]
=
self
.
_battery
return
attr
def
update
(
self
):
"""
Update the state.
"""
self
.
controller
.
get_states
([
self
.
tahoma_device
])
if
self
.
tahoma_device
.
type
==
'
rtds:RTDSSmokeSensor
'
:
if
self
.
tahoma_device
.
active_states
[
'
core:SmokeState
'
]
\
==
'
notDetected
'
:
self
.
_state
=
STATE_OFF
else
:
self
.
_state
=
STATE_ON
if
'
core:SensorDefectState
'
in
self
.
tahoma_device
.
active_states
:
# Set to 'lowBattery' for low battery warning.
self
.
_battery
=
self
.
tahoma_device
.
active_states
[
'
core:SensorDefectState
'
]
else
:
self
.
_battery
=
None
if
self
.
_state
==
STATE_ON
:
self
.
_icon
=
"
mdi:fire
"
elif
self
.
_battery
==
'
lowBattery
'
:
self
.
_icon
=
"
mdi:battery-alert
"
else
:
self
.
_icon
=
None
_LOGGER
.
debug
(
"
Update %s, state: %s
"
,
self
.
_name
,
self
.
_state
)
This diff is collapsed.
Click to expand it.
homeassistant/components/tahoma.py
+
2
−
1
View file @
6834e00b
...
...
@@ -32,7 +32,7 @@ CONFIG_SCHEMA = vol.Schema({
},
extra
=
vol
.
ALLOW_EXTRA
)
TAHOMA_COMPONENTS
=
[
'
scene
'
,
'
sensor
'
,
'
cover
'
,
'
switch
'
'
scene
'
,
'
sensor
'
,
'
cover
'
,
'
switch
'
,
'
binary_sensor
'
]
TAHOMA_TYPES
=
{
...
...
@@ -50,6 +50,7 @@ TAHOMA_TYPES = {
'
io:WindowOpenerVeluxIOComponent
'
:
'
cover
'
,
'
io:LightIOSystemSensor
'
:
'
sensor
'
,
'
rts:GarageDoor4TRTSComponent
'
:
'
switch
'
,
'
rtds:RTDSSmokeSensor
'
:
'
smoke
'
,
}
...
...
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