def test_get_significant_states_only(hass_history):
    'Test significant states when significant_states_only is set.'
    hass = hass_history
    entity_id = 'sensor.test'

    def set_state(state, **kwargs):
        'Set the state.'
        hass.states.set(entity_id, state, **kwargs)
        wait_recording_done(hass)
        return hass.states.get(entity_id)
    start = (dt_util.utcnow() - timedelta(minutes=4))
    points = []
    for i in range(1, 4):
        points.append((start + timedelta(minutes=i)))
    states = []
    with patch('homeassistant.components.recorder.dt_util.utcnow', return_value=start):
        set_state('123', attributes={'attribute': 10.64})
    with patch('homeassistant.components.recorder.dt_util.utcnow', return_value=points[0]):
        states.append(set_state('123', attributes={'attribute': 21.42}))
    with patch('homeassistant.components.recorder.dt_util.utcnow', return_value=points[1]):
        states.append(set_state('32', attributes={'attribute': 21.42}))
    with patch('homeassistant.components.recorder.dt_util.utcnow', return_value=points[2]):
        states.append(set_state('412', attributes={'attribute': 54.23}))
    hist = get_significant_states(hass, start, significant_changes_only=True)
    assert (len(hist[entity_id]) == 2)
    assert (states[0] not in hist[entity_id])
    assert (states[1] in hist[entity_id])
    assert (states[2] in hist[entity_id])
    hist = get_significant_states(hass, start, significant_changes_only=False)
    assert (len(hist[entity_id]) == 3)
    assert (states == hist[entity_id])
Test significant states when significant_states_only is set.
def test_get_significant_states_only(hass_history):
    
    hass = hass_history
    entity_id = 'sensor.test'

    def set_state(state, **kwargs):
        'Set the state.'
        hass.states.set(entity_id, state, **kwargs)
        wait_recording_done(hass)
        return hass.states.get(entity_id)
    start = (dt_util.utcnow() - timedelta(minutes=4))
    points = []
    for i in range(1, 4):
        points.append((start + timedelta(minutes=i)))
    states = []
    with patch('homeassistant.components.recorder.dt_util.utcnow', return_value=start):
        set_state('123', attributes={'attribute': 10.64})
    with patch('homeassistant.components.recorder.dt_util.utcnow', return_value=points[0]):
        states.append(set_state('123', attributes={'attribute': 21.42}))
    with patch('homeassistant.components.recorder.dt_util.utcnow', return_value=points[1]):
        states.append(set_state('32', attributes={'attribute': 21.42}))
    with patch('homeassistant.components.recorder.dt_util.utcnow', return_value=points[2]):
        states.append(set_state('412', attributes={'attribute': 54.23}))
    hist = get_significant_states(hass, start, significant_changes_only=True)
    assert (len(hist[entity_id]) == 2)
    assert (states[0] not in hist[entity_id])
    assert (states[1] in hist[entity_id])
    assert (states[2] in hist[entity_id])
    hist = get_significant_states(hass, start, significant_changes_only=False)
    assert (len(hist[entity_id]) == 3)
    assert (states == hist[entity_id])