mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 08:47:10 +00:00
This commit is contained in:
parent
a3777c4ea8
commit
97076aa3fd
@ -217,4 +217,4 @@ class BayesianBinarySensor(BinarySensorDevice):
|
|||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def async_update(self):
|
def async_update(self):
|
||||||
"""Get the latest data and update the states."""
|
"""Get the latest data and update the states."""
|
||||||
self._deviation = bool(self.probability > self._probability_threshold)
|
self._deviation = bool(self.probability >= self._probability_threshold)
|
||||||
|
@ -154,6 +154,37 @@ class TestBayesianBinarySensor(unittest.TestCase):
|
|||||||
|
|
||||||
assert state.state == 'off'
|
assert state.state == 'off'
|
||||||
|
|
||||||
|
def test_threshold(self):
|
||||||
|
"""Test sensor on probabilty threshold limits."""
|
||||||
|
config = {
|
||||||
|
'binary_sensor': {
|
||||||
|
'name':
|
||||||
|
'Test_Binary',
|
||||||
|
'platform':
|
||||||
|
'bayesian',
|
||||||
|
'observations': [{
|
||||||
|
'platform': 'state',
|
||||||
|
'entity_id': 'sensor.test_monitored',
|
||||||
|
'to_state': 'on',
|
||||||
|
'prob_given_true': 1.0,
|
||||||
|
}],
|
||||||
|
'prior':
|
||||||
|
0.5,
|
||||||
|
'probability_threshold':
|
||||||
|
1.0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert setup_component(self.hass, 'binary_sensor', config)
|
||||||
|
|
||||||
|
self.hass.states.set('sensor.test_monitored', 'on')
|
||||||
|
self.hass.block_till_done()
|
||||||
|
|
||||||
|
state = self.hass.states.get('binary_sensor.test_binary')
|
||||||
|
self.assertAlmostEqual(1.0, state.attributes.get('probability'))
|
||||||
|
|
||||||
|
assert state.state == 'on'
|
||||||
|
|
||||||
def test_multiple_observations(self):
|
def test_multiple_observations(self):
|
||||||
"""Test sensor with multiple observations of same entity."""
|
"""Test sensor with multiple observations of same entity."""
|
||||||
config = {
|
config = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user