Initialise plant attributes at startup (#19315)

* Initialise plant attributes at startup

* Pvizeli review comments

* Martin review change
This commit is contained in:
PeteBa authored and Martin Hjelmare committed 2018-12-16 21:54:33 +01:00
1 parent 92c5249746
commit 9d4de2a722
2 files changed
+22 -3

No files matched your search

+14
View File
@@ -86,6 +86,20 @@ class TestPlant(unittest.TestCase):
assert sensor.state == 'problem'
assert sensor.state_attributes['problem'] == 'battery low'
def test_initial_states(self):
"""Test plant initialises attributes if sensor already exists."""
self.hass.states.set(MOISTURE_ENTITY, 5,
{ATTR_UNIT_OF_MEASUREMENT: 'us/cm'})
plant_name = 'some_plant'
assert setup_component(self.hass, plant.DOMAIN, {
plant.DOMAIN: {
plant_name: GOOD_CONFIG
}
})
self.hass.block_till_done()
state = self.hass.states.get('plant.'+plant_name)
assert 5 == state.attributes[plant.READING_MOISTURE]
def test_update_states(self):
"""Test updating the state of a sensor.