def test_setting_sensor_value_via_mqtt_json_message(self):
        self.hass.config.components = ['mqtt']
        assert _setup_component(self.hass, sensor.DOMAIN, {
            sensor.DOMAIN: {
                'platform': 'mqtt',
                'name': 'test',
                'state_topic': 'test-topic',
                'unit_of_measurement': 'fav unit',
                'value_template': '{{ value_json.val }}'
            }
        })

        fire_mqtt_message(self.hass, 'test-topic', '{ "val": "100" }')
        self.hass.pool.block_till_done()
        state = self.hass.states.get('sensor.test')

        self.assertEqual('100', state.state)
Server side rendering for a dashboard
dataset/ETHPy150Open home-assistant/home-assistant/tests/components/sensor/test_mqtt.py/TestSensorMQTT.test_setting_sensor_value_via_mqtt_json_message--crossover with--dataset/ETHPy150Open airbnb/caravel/caravel/views.py/Caravel.dashboard