Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions homeassistant/components/binary_sensor/bayesian.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ def async_threshold_sensor_state_listener(entity, old_state,
self.watchers[platform](entity_obs)

prior = self.prior
print(self.current_obs.values())
for obs in self.current_obs.values():
prior = update_probability(prior, obs['prob_true'],
obs['prob_false'])
Expand Down Expand Up @@ -201,7 +200,7 @@ def device_state_attributes(self):
"""Return the state attributes of the sensor."""
return {
'observations': [val for val in self.current_obs.values()],
'probability': self.probability,
'probability': round(self.probability, 2),
'probability_threshold': self._probability_threshold
}

Expand Down
4 changes: 2 additions & 2 deletions tests/components/binary_sensor/test_bayesian.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def test_sensor_numeric_state(self):
'prob_false': 0.1,
'prob_true': 0.9
}], state.attributes.get('observations'))
self.assertAlmostEqual(0.7714285714285715,
self.assertAlmostEqual(0.77,
state.attributes.get('probability'))

assert state.state == 'on'
Expand Down Expand Up @@ -141,7 +141,7 @@ def test_sensor_state(self):
'prob_true': 0.8,
'prob_false': 0.4
}], state.attributes.get('observations'))
self.assertAlmostEqual(0.33333333, state.attributes.get('probability'))
self.assertAlmostEqual(0.33, state.attributes.get('probability'))

assert state.state == 'on'

Expand Down