

def create_w1_therm_sensor(sensor_type, sensor_id=None, temperature=20, w1_file=W1_FILE):
    '\n        Creates a new mocked w1 therm sensor.\n    '
    if (not sensor_id):
        sensor_id = RANDOM_SENSOR_ID()
    sensor_path = path.join(MOCKED_SENSORS_DIR, ('%s-%s' % (hex(sensor_type)[2:], sensor_id)))
    if path.exists(sensor_path):
        print('Sensor already exists')
        return sensor_id
    makedirs(sensor_path)
    data = (w1_file % (temperature * 1000))
    with open(path.join(sensor_path, W1ThermSensor.SLAVE_FILE), 'w+') as f:
        f.write(data)
        return sensor_id

dataset/ETHPy150Open timofurrer/w1thermsensor/test/test_core.py create_w1_therm_sensor/original