'Test the File sensor with JSON entries.'

@patch('os.path.isfile', Mock(return_value=True))
@patch('os.access', Mock(return_value=True))
def test_file_value_template(self):

    config = {'sensor': {'platform': 'file', 'name': 'file2', 'file_path': 'mock.file2', 'value_template': '{{    value_json.temperature    }}'}}
    data = '{"temperature":    29,    "humidity":    31}\n{"temperature":    26,    "humidity":    36}'
    m_open = MockOpen(read_data=data)
    with patch('homeassistant.components.sensor.file.open', m_open, create=True):
        assert setup_component(self.hass, 'sensor', config)
        self.hass.block_till_done()
    state = self.hass.states.get('sensor.file2')
    self.assertEqual(state.state, '26')
