'Test the history statistics sensor setup.'

def test_setup(self):

    self.init_recorder()
    config = {'history': {}, 'sensor': {'platform': 'history_stats', 'entity_id': 'binary_sensor.test_id', 'state': 'on', 'start': '{{    now().replace(hour=0).replace(minute=0).replace(second=0)    }}', 'duration': '02:00', 'name': 'Test'}}
    self.assertTrue(setup_component(self.hass, 'sensor', config))
    state = self.hass.states.get('sensor.test').as_dict()
    self.assertEqual(state['state'], '0')
