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
db06d5a0
Commit
db06d5a0
authored
9 years ago
by
Stefan Jonasson
Browse files
Options
Downloads
Patches
Plain Diff
Fixed the z-wave trigger sensor workaround
parent
04b48e06
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
homeassistant/components/binary_sensor/zwave.py
+13
-15
13 additions, 15 deletions
homeassistant/components/binary_sensor/zwave.py
with
13 additions
and
15 deletions
homeassistant/components/binary_sensor/zwave.py
+
13
−
15
View file @
db06d5a0
...
...
@@ -55,7 +55,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
])
elif
value
.
command_class
==
COMMAND_CLASS_SENSOR_BINARY
:
add_devices
([
ZWaveBinarySensor
(
value
,
"
opening
"
)])
add_devices
([
ZWaveBinarySensor
(
value
,
None
)])
class
ZWaveBinarySensor
(
BinarySensorDevice
,
ZWaveDeviceEntity
):
...
...
@@ -102,32 +102,30 @@ class ZWaveTriggerSensor(ZWaveBinarySensor):
def
__init__
(
self
,
sensor_value
,
sensor_class
,
hass
,
re_arm_sec
=
60
):
super
(
ZWaveTriggerSensor
,
self
).
__init__
(
sensor_value
,
sensor_class
)
self
.
_hass
=
hass
self
.
invalidate_after
=
dt_util
.
utcnow
()
self
.
re_arm_sec
=
re_arm_sec
self
.
invalidate_after
=
dt_util
.
utcnow
()
+
datetime
.
timedelta
(
seconds
=
self
.
re_arm_sec
)
# If it's active make sure that we set the timeout tracker
if
sensor_value
.
data
:
track_point_in_time
(
self
.
_hass
,
self
.
update_ha_state
,
self
.
invalidate_after
)
def
value_changed
(
self
,
value
):
"""
Called when a value has changed on the network.
"""
if
self
.
_value
.
value_id
==
value
.
value_id
:
self
.
update_ha_state
()
if
value
.
data
:
# only allow this value to be true for
60
secs
# only allow this value to be true for
re_arm
secs
self
.
invalidate_after
=
dt_util
.
utcnow
()
+
datetime
.
timedelta
(
seconds
=
self
.
re_arm_sec
)
track_point_in_time
(
self
.
_hass
,
self
.
update_ha_state
,
self
.
invalidate_after
)
@property
def
state
(
self
):
"""
Returns the state of the sensor.
"""
if
not
self
.
_value
.
data
or
\
(
self
.
invalidate_after
is
not
None
and
self
.
invalidate_after
<=
dt_util
.
utcnow
()):
return
False
return
True
@property
def
is_on
(
self
):
"""
Return True if the binary sensor is on.
"""
return
self
.
state
"""
Return True if movement has happened within the rearm time.
"""
return
self
.
_value
.
data
and
\
(
self
.
invalidate_after
is
None
or
self
.
invalidate_after
>
dt_util
.
utcnow
())
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